﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Amrta.Export.Excel;
using CommunitySystem.Assert;
using CommunitySystem.Ctrls;
using CommunitySystem.EmpbasicService;
using CommunitySystem.PageView;
using CommunitySystem.PageView.EmpBasicManager;
using CommunitySystem.Views;
using EHR.Common;
using org.in2bits.MyXls;



namespace CommunitySystem.PageView.EmpBasicManager
{
    public partial class EmpbasicInandOutControl : UserControl
    {
        public int KaiGuan = 0;//0为导出人员信息表，1为导出个人信息表
        private EmpbasicService.BianZhiModel model = new EmpbasicService.BianZhiModel();
        public NavMoveSwitch Nav { get; set; }
        private EmpbasicService.EmpBasicServiceClient Client = new EmpbasicService.EmpBasicServiceClient();
        public ObservableCollection<EmpbasicService.Emp_BasicInfoModel> selectedempmodel =
            new ObservableCollection<EmpbasicService.Emp_BasicInfoModel>();
        public EmpbasicInandOutControl()
        {
            InitializeComponent();
            selectedempmodel.Clear();
            ListBoxOfLife.Items.Clear();
            Client.GetPersonnelInfoExcelCompleted += new EventHandler<GetPersonnelInfoExcelCompletedEventArgs>(Client_GetPersonnelInfoExcelCompleted);
            Client.GetDengLuJueSeCompleted += new EventHandler<EmpbasicService.GetDengLuJueSeCompletedEventArgs>(Client_GetDengLuJueSeCompleted);
            Client.GetDengLuJueSeAsync(Session.LoginUser.LoginName);
            //DGRole.ColumnDisplayIndexChanged += new EventHandler<DataGridColumnEventArgs>(DGRole_ColumnDisplayIndexChanged);
            //CheckBox cb = GetCheckBoxWithParent(this.DGRole, typeof(CheckBox), "cbAll");
            //if (cb != null)
            //{
            //    cb.Checked += new RoutedEventHandler(cbAll_Checked);
            //    cb.Unchecked += new RoutedEventHandler(cbAll_Checked);
            //}
            //DGRole.LoadingRow += new EventHandler<DataGridRowEventArgs>(DGRole_LoadingRow);
            //DGRole.EnableSelect();
            Client.GetEmp_BasicInfoCountsCompleted += new EventHandler<EmpbasicService.GetEmp_BasicInfoCountsCompletedEventArgs>(Client_GetEmp_BasicInfoCountsCompleted);
            Client.GetEmp_BasicInfoCompleted += new EventHandler<EmpbasicService.GetEmp_BasicInfoCompletedEventArgs>(Client_GetEmp_BasicInfoCompleted);
            Client.GetLieByUserIDCompleted += new EventHandler<GetLieByUserIDCompletedEventArgs>(Client_GetLieByUserIDCompleted);
            Client.UpdateLieCompleted += new EventHandler<UpdateLieCompletedEventArgs>(Client_UpdateLieCompleted);
            Client.GetOrgForHRModelbyIDsCompleted += new EventHandler<EmpbasicService.GetOrgForHRModelbyIDsCompletedEventArgs>(Client_GetOrgForHRModelbyIDsCompleted);
            Client.GetDengLuOrgCompleted += new EventHandler<EmpbasicService.GetDengLuOrgCompletedEventArgs>(Client_GetDengLuOrgCompleted);
            Client.GetOrgForHRModelCompleted += new EventHandler<EmpbasicService.GetOrgForHRModelCompletedEventArgs>(Client_GetOrgForHRModelCompleted);
            Client.DaoRuAllCompleted += new EventHandler<EmpbasicService.DaoRuAllCompletedEventArgs>(Client_DaoRuAllCompleted);
            Client.ShanChuDaoRuAllCompleted += new EventHandler<ShanChuDaoRuAllCompletedEventArgs>(Client_ShanChuDaoRuAllCompleted);
            Client.CanDaoRuAllCompleted += new EventHandler<EmpbasicService.CanDaoRuAllCompletedEventArgs>(Client_CanDaoRuAllCompleted);
            //LoadData("0");
        }
        void LoadData(string orgid)
        {
            Client.GetEmp_BasicInfoCountsAsync(orgid, "0", "", type, "在职", "");
            //Client.GetEmp_BasicInfoCountsCompleted += (sender, e) =>
            //                                      {
            //                                          int count = e.Result;
            //                                          List<int> source = new List<int>();
            //                                          for (int i = 0; i < count; i++)
            //                                          {
            //                                              source.Add(i + 1);
            //                                              dataPager1.PageSize = 1;
            //                                              dataPager1.Source = source;
            //                                          }
            //                                      };
            Client.GetEmp_BasicInfoAsync(orgid, "0", "", type, 0, 20, "在职", "");
        }
        void Client_GetEmp_BasicInfoCountsCompleted(object sender, EmpbasicService.GetEmp_BasicInfoCountsCompletedEventArgs e)
        {
            int count = e.Result;
            ObservableCollection<int> source = new ObservableCollection<int>();
            for (int i = 0; i < count; i++)
            {
                source.Add(i + 1);

            }
            PagedCollectionView pcv = new PagedCollectionView(source);
            dataPager1.PageSize = 1;
            dataPager1.Source = pcv;
        }
        private void dataPager1_PageIndexChanged(object sender, EventArgs e)
        {
            int index = dataPager1.PageIndex;
            if (DGRole.ItemsSource != null)
            {
                foreach (EmpbasicService.Emp_BasicInfoModel i in (ObservableCollection<EmpbasicService.Emp_BasicInfoModel>)DGRole.ItemsSource)
                {
                    if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(i);
                    }
                    if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                    }
                }
            }
            string ss = "";
            foreach (string ii in orgids)
                ss += ii + ",";
            if (string.IsNullOrEmpty(ss))
            {
                ss = "0";
            }
            else
            {
                    ss = ss.Substring(0, ss.Length - 1);
            }

            Client.GetEmp_BasicInfoAsync(ss, "0", ChaName.Text, type, index * 20, index * 20 + 20, "在职", "");
        }

        public ObservableCollection<EmpbasicService.OrgForHRModel> OrgList =
            new ObservableCollection<EmpbasicService.OrgForHRModel>();
        void Client_GetDengLuJueSeCompleted(object sender, EmpbasicService.GetDengLuJueSeCompletedEventArgs e)
        {
            if (e.Result != "人事干部")
            {
                if (TreeOfLife.ItemsSource != null) TreeOfLife.ItemsSource = null;
                TreeOfLife.Visibility = System.Windows.Visibility.Visible;
                ListBoxOfLife.Visibility = System.Windows.Visibility.Collapsed;
                //colLeft.Width = new GridLength(265);
                //colSplit.Width = new GridLength(10);
                LoadData("0");
                Client.GetOrgForHRModelAsync(0);
            }
            else
            {
                TreeOfLife.Visibility = System.Windows.Visibility.Collapsed;
                ListBoxOfLife.Visibility = System.Windows.Visibility.Visible;
                
                Client.GetDengLuOrgAsync(Session.LoginUser.LoginName);
                //colLeft.Width = new GridLength(0);
                //colSplit.Width = new GridLength(0);
            }
        }
        public String[] Oldorgids;
        void Client_GetDengLuOrgCompleted(object sender, EmpbasicService.GetDengLuOrgCompletedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Result))
            {
                Oldorgids = e.Result.Split(',');
            }
            
            Client.GetOrgForHRModelbyIDsAsync("(" + e.Result + ")");
        }

        void Client_GetOrgForHRModelbyIDsCompleted(object sender, EmpbasicService.GetOrgForHRModelbyIDsCompletedEventArgs e)
        {
            ListBoxOfLife.ItemsSource = e.Result;
            ListBoxOfLife.SelectedIndex = 0;
            orgid = Convert.ToInt32(e.Result[0].ID);
            //if (!orgids.Contains(orgid.ToString())) orgids.Add(orgid.ToString());
            //string ss = "";
            //foreach (string ii in orgids)
            //    ss += ii + ",";
            //ss = ss.Substring(0, ss.Length - 1);
            orgids.Clear();
            orgids.Add(orgid.ToString());
            LoadData(orgids[0]);
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            orgid = Convert.ToInt32(((OrgForHRModel)(ListBoxOfLife.SelectedItem)).ID);
            orgids.Clear();
            orgids.Add(orgid.ToString());
            LoadData(orgids[0]);
        }

        void Client_GetOrgForHRModelCompleted(object sender, EmpbasicService.GetOrgForHRModelCompletedEventArgs e)
        {
            OrgList = e.Result;
            forumList.Clear();
            foreach (EmpbasicService.OrgForHRModel i in e.Result)
            {
                forumList.Add(i);
            }
            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "全部单位", Name = "组织机构" });
            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "组织机构", Name = "党群系统" });
            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "组织机构", Name = "政法系统" });

            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "组织机构", Name = "行政系统" });
            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "组织机构", Name = "参公系统" });
            //forumList.Add(new EmpbasicService.OrgForHRModel() { ID = 1, Type = "组织机构", Name = "地区系统" });
            AddTreeNode("全部单位", null);
        }

        public ObservableCollection<EmpbasicService.Emp_BasicInfoModel> empmodel =
            new ObservableCollection<EmpbasicService.Emp_BasicInfoModel>();
        void Client_GetEmp_BasicInfoCompleted(object sender, EmpbasicService.GetEmp_BasicInfoCompletedEventArgs e)
        {
            //List<EmpbasicService.Emp_BasicInfoModel> tt = null;
            //if (DGRole.SelectedItems.Count > 0)
            //{
            //    tt = DGRole.GetSelectedItems<EmpbasicService.Emp_BasicInfoModel>();
            //    if (tt.Count > 0)
            //    {
            //        foreach (EmpbasicService.Emp_BasicInfoModel i in tt)
            //        {
            //            if (e.Result.Where(p => p.ID == i.ID).FirstOrDefault() == null)
            //                e.Result.Add(i);
            //            else e.Result.Remove(i);

            //        }
            //    }
            //}
            foreach (EmpbasicService.Emp_BasicInfoModel i in e.Result)
            {
                if (empmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                {
                    empmodel.Add(i);
                }
            }
            foreach (EmpbasicService.Emp_BasicInfoModel i in selectedempmodel)
            {
                if (e.Result.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == true)
                {
                    e.Result.Where(p => p.ID == i.ID).FirstOrDefault().IsSelected = true;
                }
            }
            DGRole.ItemsSource = e.Result;
            
            Client.GetLieByUserIDAsync(Session.LoginUser.UserID);

            //if (tt != null && tt.Count > 0)
            //{
            //    foreach (EmpbasicService.Emp_BasicInfoModel i in tt)
            //    {
            //        DGRole.SelectedItems.Add(i);
            //    }
            //}
        }

        private string Contents { get; set; }

        void DGRole_ColumnDisplayIndexChanged(object sender, DataGridColumnEventArgs e)
        {
            //string result = string.Empty;
            //foreach(var column in DGRole.Columns.Where(c=>c.Visibility == System.Windows.Visibility.Visible))
            //{
            //    DataGridTextColumn tc = column as DataGridTextColumn;
            //    if (tc != null)
            //    {
            //        //result += column.Header.ToString() + "-" + column.DisplayIndex+";";
            //    }
            //}
            for (int i = 0; i < 41; i++)
            {
                if (!string.IsNullOrEmpty(e.Column.Header.ToString()) && e.Column.Header.ToString() == shuzu[i].Split('-')[0])
                {
                    shuzu[i] = shuzu[i].Split('-')[0] + "-" + shuzu[i].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
                }
            }
            //switch (e.Column.Header.ToString())
            //{
            //    case "姓名":
            //        shuzu[0] = shuzu[0].Split('-')[0] + "-" + shuzu[0].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "证件号码":
            //        shuzu[1] = shuzu[1].Split('-')[0] + "-" + shuzu[1].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "性别":
            //        shuzu[2] = shuzu[2].Split('-')[0] + "-" + shuzu[2].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "出生日期":
            //        shuzu[3] = shuzu[3].Split('-')[0] + "-" + shuzu[3].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "退休时间":
            //        shuzu[4] = shuzu[4].Split('-')[0] + "-" + shuzu[4].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "距离退休年限":
            //        shuzu[5] = shuzu[5].Split('-')[0] + "-" + shuzu[5].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "出生地":
            //        shuzu[6] = shuzu[6].Split('-')[0] + "-" + shuzu[6].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "籍贯":
            //        shuzu[7] = shuzu[7].Split('-')[0] + "-" + shuzu[7].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "民族":
            //        shuzu[8] = shuzu[8].Split('-')[0] + "-" + shuzu[8].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "政治面貌":
            //        shuzu[9] = shuzu[9].Split('-')[0] + "-" + shuzu[9].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "健康状况":
            //        shuzu[10] = shuzu[10].Split('-')[0] + "-" + shuzu[10].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "参加工作日期":
            //        shuzu[11] = shuzu[11].Split('-')[0] + "-" + shuzu[11].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "现工作单位":
            //        shuzu[12] = shuzu[12].Split('-')[0] + "-" + shuzu[12].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "现工作部门":
            //        shuzu[13] = shuzu[13].Split('-')[0] + "-" + shuzu[13].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "公务员登记号":
            //        shuzu[14] = shuzu[14].Split('-')[0] + "-" + shuzu[14].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "人员编制类型":
            //        shuzu[15] = shuzu[15].Split('-')[0] + "-" + shuzu[15].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "进本单位时间":
            //        shuzu[16] = shuzu[16].Split('-')[0] + "-" + shuzu[16].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "获本区公务员身份方式":
            //        shuzu[17] = shuzu[17].Split('-')[0] + "-" + shuzu[17].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "户籍所在地":
            //        shuzu[18] = shuzu[18].Split('-')[0] + "-" + shuzu[18].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "婚姻状况":
            //        shuzu[19] = shuzu[19].Split('-')[0] + "-" + shuzu[19].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "家庭住址":
            //        shuzu[20] = shuzu[20].Split('-')[0] + "-" + shuzu[20].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "住宅电话":
            //        shuzu[21] = shuzu[21].Split('-')[0] + "-" + shuzu[21].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;

            //    case "个人身份":
            //        shuzu[22] = shuzu[22].Split('-')[0] + "-" + shuzu[22].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "入党时间":
            //        shuzu[23] = shuzu[23].Split('-')[0] + "-" + shuzu[23].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "专长":
            //        shuzu[24] = shuzu[24].Split('-')[0] + "-" + shuzu[24].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "专业技术职务":
            //        shuzu[25] = shuzu[25].Split('-')[0] + "-" + shuzu[25].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "人员类别":
            //        shuzu[26] = shuzu[26].Split('-')[0] + "-" + shuzu[26].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "公务员登记时间":
            //        shuzu[27] = shuzu[27].Split('-')[0] + "-" + shuzu[27].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "职务代码":
            //        shuzu[28] = shuzu[28].Split('-')[0] + "-" + shuzu[28].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "现任职务":
            //        shuzu[29] = shuzu[29].Split('-')[0] + "-" + shuzu[29].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "职务层次":
            //        shuzu[30] = shuzu[30].Split('-')[0] + "-" + shuzu[30].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "职务属性":
            //        shuzu[31] = shuzu[31].Split('-')[0] + "-" + shuzu[31].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "批准时间":
            //        shuzu[32] = shuzu[32].Split('-')[0] + "-" + shuzu[32].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "任职方式":
            //        shuzu[33] = shuzu[33].Split('-')[0] + "-" + shuzu[33].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "任现职务层次时间":
            //        shuzu[34] = shuzu[34].Split('-')[0] + "-" + shuzu[34].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "任现职务属性时间":
            //        shuzu[35] = shuzu[35].Split('-')[0] + "-" + shuzu[35].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;

            //    case "学历名称":
            //        shuzu[36] = shuzu[36].Split('-')[0] + "-" + shuzu[36].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "学习形式":
            //        shuzu[37] = shuzu[37].Split('-')[0] + "-" + shuzu[37].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "毕业日期":
            //        shuzu[38] = shuzu[38].Split('-')[0] + "-" + shuzu[38].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "学校":
            //        shuzu[39] = shuzu[39].Split('-')[0] + "-" + shuzu[39].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //    case "所学专业":
            //        shuzu[40] = shuzu[40].Split('-')[0] + "-" + shuzu[40].Split('-')[1] + "-" + e.Column.DisplayIndex.ToString();
            //        break;
            //}

        }
        private void SavePeiZhiData_Click(object sender, RoutedEventArgs e)
        {
            string con = "";
            foreach (string i in shuzu)
            {
                con = con + i + ",";
            }
            con = con.Substring(0, con.Length - 1);
            model1.UserID = Session.LoginUser.UserID;
            model1.Content = con;
            
            Client.UpdateLieAsync(model1);
        }
        void Client_UpdateLieCompleted(object sender, UpdateLieCompletedEventArgs e)
        {
            MessageBox.Show("保存成功！");
        }

        private string[] PaiXu(string[] list)
        {
            if (list.Count() > 0)
            {
                for (int i = 0; i < list.Count(); i++)
                {
                    for (int j = i; j < list.Count(); j++)
                    {
                        if (Convert.ToInt32(list[i].Split('-')[2]) > Convert.ToInt32(list[j].Split('-')[2]))
                        {
                            string k = list[j];
                            list[j] = list[i];
                            list[i] = k;
                        }
                    }
                }
            }
            return list;
        }
        private PeiZhiLieModel model1 = new PeiZhiLieModel();
        private string[] shuzu = null;

        void Client_GetLieByUserIDCompleted(object sender, GetLieByUserIDCompletedEventArgs e)
        {
            //while(DGRole.Columns.Count > 2)
            //{
            //    DGRole.Columns.RemoveAt(2);
            //}
            if (e.Result != null)
            {
                model1 = e.Result;
                Contents = ((PeiZhiLieModel)e.Result).Content;
            }
            if (string.IsNullOrEmpty(Contents))
            {
                Contents =
                     @"姓名-true-100,证件号码-true-100,性别-true-100,出生日期-true-100,退休时间-true-100,距离退休年限-true-100,出生地-true-100,籍贯-true-100,民族-true-100,政治面貌-true-100,健康状况-true-100,参加工作日期-true-100,现工作单位-true-100,现工作部门-true-100,公务员登记号-true-100,人员编制类型-true-100,进本单位时间-true-100,获本区公务员身份方式-true-100,户籍所在地-true-100,婚姻状况-true-100,家庭住址-true-100,住宅电话-true-100,个人身份-true-100,入党时间-true-100,专长-true-100,专业技术职务-true-100,人员类别-true-100,公务员登记时间-true-100,职务代码-true-100,现任职务-true-100,职务层次-true-100,职务属性-true-100,批准时间-true-100,任职方式-true-100,任现职务层次时间-true-100,任现职务属性时间-true-100,学历名称-true-100,学习形式-true-100,毕业日期-true-100,学校-true-100,所学专业-true-100";
            }
            if (DGRole.Columns.Count == 2)
            {
                shuzu = Contents.Split(',');
                shuzu = PaiXu(shuzu);
                //if(Convert.ToInt32(shuzu[0].Split('-')[2]))
                foreach (string i in shuzu)
                {
                    if (i.Split('-')[0] == "姓名" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "姓名";
                        column.Binding = new Binding("Name");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "证件号码" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "证件号码";
                        column.Binding = new Binding("CardNo");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "性别" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "性别";
                        column.Binding = new Binding("Gender");
                        column.Width = new DataGridLength(80);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "出生日期" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "出生日期";
                        Binding binding = new Binding("Birthday");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "退休时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "退休时间";
                        Binding binding = new Binding("TuiXiuDateString");
                        //binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "距离退休年限" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "距离退休年限";
                        column.Binding = new Binding("JuTuiXiuDate");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "出生地" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "出生地";
                        column.Binding = new Binding("BirthPlace");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "籍贯" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "籍贯";
                        column.Binding = new Binding("NativePlace");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "民族" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "民族";
                        column.Binding = new Binding("Native");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "政治面貌" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "政治面貌";
                        column.Binding = new Binding("Political");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "健康状况" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "健康状况";
                        column.Binding = new Binding("Health");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "参加工作日期" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "参加工作日期";
                        Binding binding = new Binding("WorkDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "现工作单位" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "现工作单位";
                        column.Binding = new Binding("OrgName");
                        column.Width = new DataGridLength(250);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "现工作部门" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "现工作部门";
                        column.Binding = new Binding("PositionName");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "公务员登记号" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "公务员登记号";
                        column.Binding = new Binding("RegisterNo");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "人员编制类型" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "人员编制类型";
                        column.Binding = new Binding("OrganizationType");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "进本单位时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "进本单位时间";
                        Binding binding = new Binding("NowWorkDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "获本区公务员身份方式" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "获本区公务员身份方式";
                        column.Binding = new Binding("HuoDeFangShi");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "户籍所在地" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "户籍所在地";
                        column.Binding = new Binding("HouseholdRegister");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "婚姻状况" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "婚姻状况";
                        column.Binding = new Binding("Marriage");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "家庭住址" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "家庭住址";
                        column.Binding = new Binding("HomeAddress");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "住宅电话" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "住宅电话";
                        column.Binding = new Binding("Phone");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "个人身份" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "个人身份";
                        column.Binding = new Binding("EmpIdentity");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "入党时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "入党时间";
                        Binding binding = new Binding("PartyTime");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "专长" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "专长";
                        column.Binding = new Binding("Special");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "专业技术职务" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "专业技术职务";
                        column.Binding = new Binding("TechnicalPositions");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "人员类别" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "人员类别";
                        column.Binding = new Binding("PersonnelType");
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "公务员登记时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "公务员登记时间";
                        Binding binding = new Binding("RegisterDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "职务代码" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "职务代码";
                        column.Binding = new Binding("DutyNo");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "现任职务" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "现任职务";
                        column.Binding = new Binding("DutyName");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "职务层次" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "职务层次";
                        column.Binding = new Binding("DutyLevel");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "职务属性" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "职务属性";
                        column.Binding = new Binding("DutyAttribute");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "任职方式" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "任职方式";
                        column.Binding = new Binding("ServiceMode");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "批准时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "批准时间";
                        Binding binding = new Binding("OKDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "任现职务层次时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "任现职务层次时间";
                        Binding binding = new Binding("JobDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "任现职务属性时间" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "任现职务属性时间";
                        Binding binding = new Binding("RXRZWSXSJ");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "学历名称" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "学历名称";
                        column.Binding = new Binding("EducationName");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "学习形式" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "学习形式";
                        column.Binding = new Binding("EducationType");
                        column.Width = new DataGridLength(100);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "毕业日期" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "毕业日期";
                        Binding binding = new Binding("GraduationDate");
                        binding.StringFormat = "yyyy-MM-dd";
                        column.Binding = binding;
                        column.Width = new DataGridLength(120);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "学校" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "学校";
                        column.Binding = new Binding("School");
                        column.Width = new DataGridLength(200);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                    if (i.Split('-')[0] == "所学专业" && i.Split('-')[1] == "true")
                    {
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.Header = "所学专业";
                        column.Binding = new Binding("Professional");
                        column.Width = new DataGridLength(150);
                        column.IsReadOnly = true;
                         
                        DGRole.Columns.Add(column);
                    }
                }
                DGRole.Columns.OrderBy(p => p.DisplayIndex);
            }



        }

        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            foreach (EmpbasicService.Emp_BasicInfoModel p in DGRole.ItemsSource)
            {
                p.IsSelected = (bool)cb.IsChecked;
                //CheckBox cb1 = DGRole.Columns[0].GetCellContent(p) as CheckBox;
                //cb1.IsChecked = p.IsSelected;
                if (p.IsSelected)
                {
                    if (selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(p);
                    }
                }
                else
                {
                    if (selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault() != null)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault());
                    }
                }
            }

        }

        ObservableCollection<EmpbasicService.OrgForHRModel> forumList = new ObservableCollection<EmpbasicService.OrgForHRModel>();

        public string IDS = "";
        private void AddTreeNode(string type, TreeViewItem treeViewItem)
        {
            List<EmpbasicService.OrgForHRModel> result = (from forumInfo in forumList
                                                          where forumInfo.Type == type
                                                          select forumInfo).ToList<EmpbasicService.OrgForHRModel>();

            if (result.Count > 0)
            {
                foreach (EmpbasicService.OrgForHRModel foruminfo in result)
                {
                    TreeViewItem objTreeNode = new TreeViewItem();

                    //StackPanel sp = new StackPanel();
                    CheckBox cb = new CheckBox();
                    cb.Content = foruminfo.Name;
                    cb.Tag = objTreeNode;
                    cb.DataContext = foruminfo;
                    //sp.Children.Add(cb);
                    cb.Click += new RoutedEventHandler(cb_Checked);
                    objTreeNode.Header = cb;
                    //objTreeNode.Header = foruminfo.Name;
                    //objTreeNode.DataContext = foruminfo;
                    //objTreeNode.Tag = foruminfo.ID;
                    if ((objTreeNode.Header as CheckBox).Content.ToString() == "组织机构") objTreeNode.IsExpanded = true;

                    //此样式将会添加的所有叶子结点上
                    //objTreeNode.ItemContainerStyle = this.Resources["RedItemStyle"] as Style;

                    //添加根节点
                    if (treeViewItem == null)
                    {
                        TreeOfLife.Items.Add(objTreeNode);
                    }
                    else
                    {
                        treeViewItem.Items.Add(objTreeNode);
                    }
                    AddTreeNode(foruminfo.Name, objTreeNode);
                }
            }
        }
        void cb_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            EmpbasicService.OrgForHRModel rm = cb.DataContext as EmpbasicService.OrgForHRModel;
            if (cb.IsChecked == true)
            {
                //if (orgids != null)
                //{
                //orgid = Convert.ToInt32(((EmpbasicService.OrgForHRModel)cb.DataContext).ID);
                //tbTitle.Text = cb.Content.ToString();
                if (!orgids.Contains(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString()))
                    orgids.Add(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString());
                string ss = "";
                foreach (string i in orgids)
                    ss += i + ",";
                if(ss.Length>1)
                    ss = ss.Substring(0, ss.Length - 1);
                LoadData(ss);
                CheckChildItem(cb.Tag as TreeViewItem);
            }
            else
            {
                //if (orgids != null)
                //{
                if (orgids != null)
                {
                    if (orgids.Contains(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString()))
                        orgids.Remove(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString());
                }
                string ss = "";
                foreach (string i in orgids)
                    ss += i + ",";
                if(ss.Length>1)
                    ss = ss.Substring(0, ss.Length - 1);
                LoadData(ss);
                UnCheckChildItem(cb.Tag as TreeViewItem);
            }
        }
        void CheckParentItem(TreeViewItem item)
        {
            TreeViewItem tvi = item.GetParentTreeViewItem();
            if (tvi != null)
            {
                CheckBox cb = tvi.Header as CheckBox;
                cb.IsChecked = true;
                CheckParentItem(tvi);
            }
        }

        void CheckChildItem(TreeViewItem item)
        {
            foreach (TreeViewItem tvi in item.Items)
            {
                if (tvi != null)
                {
                    CheckBox cb = tvi.Header as CheckBox;
                    cb.IsChecked = true;
                    if (!orgids.Contains(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString()))
                        orgids.Add(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString());
                    CheckChildItem(tvi);
                }
            }
        }
        void UnCheckChildItem(TreeViewItem item)
        {
            foreach (TreeViewItem tvi in item.Items)
            {
                if (tvi != null)
                {
                    CheckBox cb = tvi.Header as CheckBox;
                    cb.IsChecked = false;
                    if (orgids.Contains(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString()))
                        orgids.Remove(((EmpbasicService.OrgForHRModel)cb.DataContext).ID.ToString());
                    UnCheckChildItem(tvi);
                }
            }
        }
        private void ChaData_Click(object sender, RoutedEventArgs e)
        {
            string ss = "";
            foreach (string ii in orgids)
                ss += ii + ",";
            if (ss.Length > 1)
                ss = ss.Substring(0, ss.Length - 1);
            else ss = "0";
            Client.GetEmp_BasicInfoCompleted -= new EventHandler<EmpbasicService.GetEmp_BasicInfoCompletedEventArgs>(Client_GetEmp_BasicInfoCompleted);
            Client.GetEmp_BasicInfoCompleted += new EventHandler<EmpbasicService.GetEmp_BasicInfoCompletedEventArgs>(Client_GetEmp_BasicInfoCompleted);
            Client.GetEmp_BasicInfoAsync(ss, "0", ChaName.Text, type, 0, 20, "在职", "");
            Client.GetEmp_BasicInfoCountsAsync(ss, "0", ChaName.Text, type, "在职", "");
            Client.GetEmp_BasicInfoCountsCompleted += new EventHandler<EmpbasicService.GetEmp_BasicInfoCountsCompletedEventArgs>(Client_GetEmp_BasicInfoCountsCompleted);
        }
        public int orgid { get; set; }
        public List<string> orgids = new List<string>();
        public string type { get; set; }

        private GridLength _lastColLeftLength;
        private GridLength _lastColRightLength;
        private void GridSpliteTo_ToLeft(object sender, EventArgs e)
        {
            //已经到最左边，直接返回
            if (colLeft.Width.Value == 0.0)
            {
                return;
            }

            //
            if (colRight.Width.Value == 0)
            {
                colLeft.Width = _lastColLeftLength;
                colRight.Width = _lastColRightLength;
            }
            else
            {
                _lastColLeftLength = colLeft.Width;
                _lastColRightLength = colRight.Width;

                colLeft.Width = new GridLength(0);
                colRight.Width = new GridLength(150, GridUnitType.Star);
            }
        }

        private void GridSpliteTo_ToRight(object sender, EventArgs e)
        {
            if (colRight.Width.Value == 0)
            {
                return;
            }

            if (colLeft.Width.Value == 0)
            {
                colLeft.Width = _lastColLeftLength;
                colRight.Width = _lastColRightLength;
            }
            else
            {
                _lastColLeftLength = colLeft.Width;
                _lastColRightLength = colRight.Width;

                colRight.Width = new GridLength(0);
                colLeft.Width = new GridLength(300, GridUnitType.Star);
            }
        }
        #region 数据表导出
        //选中的empbasic的数据源
        ObservableCollection<EmpbasicService.Emp_BasicInfoModel> temp =
            new ObservableCollection<EmpbasicService.Emp_BasicInfoModel>();
        #region 单位数据表导出
        /// <summary>
        /// 单位数据表导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOut1_Click(object sender, RoutedEventArgs e)
        {
            temp.Clear();
            KaiGuan = 0;
            IDS = "";
            if (orgids != null && orgids.Count > 0)
            {
                foreach (string i in orgids)
                {
                    IDS = IDS + i + ",";
                }
            }
            else
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择单位");
                return;
            }
            var downLoad = new SaveFileDialog()
              {
                  //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls", //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                  Filter = "Excel files(2003) (*.xls)|*.xls",
              };
            if (downLoad.ShowDialog() == true)
            {
                ss = downLoad.OpenFile();
                Client.GetDanWeiEmp_BasicInfosCompleted -=
                    new EventHandler<EmpbasicService.GetDanWeiEmp_BasicInfosCompletedEventArgs>(
                        Client_GetDanWeiEmp_BasicInfosCompleted);
                Client.GetDanWeiEmp_BasicInfosCompleted +=
                    new EventHandler<EmpbasicService.GetDanWeiEmp_BasicInfosCompletedEventArgs>(
                        Client_GetDanWeiEmp_BasicInfosCompleted);
                Client.GetDanWeiEmp_BasicInfosAsync(IDS.Substring(0, IDS.Length - 1), "在职", ss);


            }
        }

        void Client_GetDanWeiEmp_BasicInfosCompleted(object sender, EmpbasicService.GetDanWeiEmp_BasicInfosCompletedEventArgs e)
        {
            var ss = e.UserState;
            if (e.Result.Count <= 0)
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("所选单位没有人员可以导出！");
                return;
            }
            else
            {
                string ids = "";
                foreach (var i in e.Result)
                {
                    ids = ids + i.ID.ToString() + ",";
                    temp.Add(i);
                }

                //if (downLoad.ShowDialog() == true)
                //{
                //    s = downLoad.OpenFile();
                Client.GetEmp_AssessmentModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs>(
                        Client_GetEmp_AssessmentModelCompleted);
                Client.GetEmp_AssessmentModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs>(
                        Client_GetEmp_AssessmentModelCompleted);
                Client.GetEmp_AssessmentModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_DegreeModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_DegreeModelCompletedEventArgs>(
                        Client_GetEmp_DegreeModelCompleted);
                Client.GetEmp_DegreeModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_DegreeModelCompletedEventArgs>(
                        Client_GetEmp_DegreeModelCompleted);
                Client.GetEmp_DegreeModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_DutysCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_DutysCompletedEventArgs>(Client_GetEmp_DutysCompleted);
                Client.GetEmp_DutysCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_DutysCompletedEventArgs>(Client_GetEmp_DutysCompleted);
                Client.GetEmp_DutysAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_EducationModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_EducationModelCompletedEventArgs>(
                        Client_GetEmp_EducationModelCompleted);
                Client.GetEmp_EducationModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_EducationModelCompletedEventArgs>(
                        Client_GetEmp_EducationModelCompleted);
                Client.GetEmp_EducationModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_FamilyRelationModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs>(
                        Client_GetEmp_FamilyRelationModelCompleted);
                Client.GetEmp_FamilyRelationModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs>(
                        Client_GetEmp_FamilyRelationModelCompleted);
                Client.GetEmp_FamilyRelationModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_PunishmentModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs>(
                        Client_GetEmp_PunishmentModelCompleted);
                Client.GetEmp_PunishmentModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs>(
                        Client_GetEmp_PunishmentModelCompleted);
                Client.GetEmp_PunishmentModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_ResumeCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_ResumeCompletedEventArgs>(Client_GetEmp_ResumeCompleted);
                Client.GetEmp_ResumeCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_ResumeCompletedEventArgs>(Client_GetEmp_ResumeCompleted);
                Client.GetEmp_ResumeAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_RewardInfoModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs>(
                        Client_GetEmp_RewardInfoModelCompleted);
                Client.GetEmp_RewardInfoModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs>(
                        Client_GetEmp_RewardInfoModelCompleted);
                Client.GetEmp_RewardInfoModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);
                //}
            }
        }
        #endregion

        private Stream DataSheetExport = null;
        /// <summary>
        /// 数据表导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOut_Click(object sender, RoutedEventArgs e)
        {
            temp.Clear();
            KaiGuan = 0;
            if (DGRole.ItemsSource != null)
            {
                foreach (EmpbasicService.Emp_BasicInfoModel i in (ObservableCollection<EmpbasicService.Emp_BasicInfoModel>)DGRole.ItemsSource)
                {
                    if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(i);
                    }
                    if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                    }
                }
            }
            if (selectedempmodel.Count <= 0)
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择要导出的数据！");
                return;
            }
            string ids = "";
            foreach (var i in selectedempmodel)
            {
                ids = ids + i.ID.ToString() + ",";
                temp.Add(empmodel.Where(p => p.ID == i.ID).FirstOrDefault());
            }
            var downLoad = new SaveFileDialog()
            {
                //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls", //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                Filter = "Excel files(2003) (*.xls)|*.xls",
            };
            if (downLoad.ShowDialog() == true)
            {
                //ss = downLoad.OpenFile();
                DataSheetExport = downLoad.OpenFile();
                Client.GetEmp_AssessmentModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs>(
                        Client_GetEmp_AssessmentModelCompleted);
                Client.GetEmp_AssessmentModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs>(
                        Client_GetEmp_AssessmentModelCompleted);
                Client.GetEmp_AssessmentModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_DegreeModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_DegreeModelCompletedEventArgs>(
                        Client_GetEmp_DegreeModelCompleted);
                Client.GetEmp_DegreeModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_DegreeModelCompletedEventArgs>(
                        Client_GetEmp_DegreeModelCompleted);
                Client.GetEmp_DegreeModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_DutysCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_DutysCompletedEventArgs>(Client_GetEmp_DutysCompleted);
                Client.GetEmp_DutysCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_DutysCompletedEventArgs>(Client_GetEmp_DutysCompleted);
                Client.GetEmp_DutysAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0);

                Client.GetEmp_EducationModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_EducationModelCompletedEventArgs>(
                        Client_GetEmp_EducationModelCompleted);
                Client.GetEmp_EducationModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_EducationModelCompletedEventArgs>(
                        Client_GetEmp_EducationModelCompleted);
                Client.GetEmp_EducationModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_FamilyRelationModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs>(
                        Client_GetEmp_FamilyRelationModelCompleted);
                Client.GetEmp_FamilyRelationModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs>(
                        Client_GetEmp_FamilyRelationModelCompleted);
                Client.GetEmp_FamilyRelationModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_PunishmentModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs>(
                        Client_GetEmp_PunishmentModelCompleted);
                Client.GetEmp_PunishmentModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs>(
                        Client_GetEmp_PunishmentModelCompleted);
                Client.GetEmp_PunishmentModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_ResumeCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_ResumeCompletedEventArgs>(Client_GetEmp_ResumeCompleted);
                Client.GetEmp_ResumeCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_ResumeCompletedEventArgs>(Client_GetEmp_ResumeCompleted);
                Client.GetEmp_ResumeAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);

                Client.GetEmp_RewardInfoModelCompleted -=
                    new EventHandler<EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs>(
                        Client_GetEmp_RewardInfoModelCompleted);
                Client.GetEmp_RewardInfoModelCompleted +=
                    new EventHandler<EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs>(
                        Client_GetEmp_RewardInfoModelCompleted);
                Client.GetEmp_RewardInfoModelAsync("(" + ids.Substring(0, ids.Length - 1) + ")", 0, ss);
            }
        }

        #region 导出时候用到的相关子集
        public ObservableCollection<EmpbasicService.Emp_AssessmentModel> empassessment =
            new ObservableCollection<EmpbasicService.Emp_AssessmentModel>();
        private bool empassessmentbool = false;
        void Client_GetEmp_AssessmentModelCompleted(object sender, EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                empassessment = e.Result;
            empassessmentbool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_DegreeModel> degree =
            new ObservableCollection<EmpbasicService.Emp_DegreeModel>();
        private bool degreebool = false;
        void Client_GetEmp_DegreeModelCompleted(object sender, EmpbasicService.GetEmp_DegreeModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                degree = e.Result;
            degreebool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_Duty> duty =
            new ObservableCollection<EmpbasicService.Emp_Duty>();
        private bool dutybool = false;
        void Client_GetEmp_DutysCompleted(object sender, EmpbasicService.GetEmp_DutysCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                duty = e.Result;
            dutybool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_EducationModel> education =
            new ObservableCollection<EmpbasicService.Emp_EducationModel>();
        private bool educationbool = false;
        void Client_GetEmp_EducationModelCompleted(object sender, EmpbasicService.GetEmp_EducationModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                education = e.Result;
            educationbool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_FamilyRelationModel> family =
            new ObservableCollection<EmpbasicService.Emp_FamilyRelationModel>();
        private bool familybool = false;
        void Client_GetEmp_FamilyRelationModelCompleted(object sender, EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                family = e.Result;
            familybool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_PunishmentModel> punish =
            new ObservableCollection<EmpbasicService.Emp_PunishmentModel>();
        private bool punishbool = false;
        void Client_GetEmp_PunishmentModelCompleted(object sender, EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                punish = e.Result;
            punishbool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_ResumeModel> resume =
            new ObservableCollection<EmpbasicService.Emp_ResumeModel>();
        private bool resumebool = false;
        private Stream ss = null;
        void Client_GetEmp_ResumeCompleted(object sender, EmpbasicService.GetEmp_ResumeCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                resume = e.Result;
            resumebool = true;
            TryPageInit(ss);
        }

        public ObservableCollection<EmpbasicService.Emp_RewardInfoModel> reward =
            new ObservableCollection<EmpbasicService.Emp_RewardInfoModel>();
        private bool rewardbool = false;
        void Client_GetEmp_RewardInfoModelCompleted(object sender, EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs e)
        {
            ss = e.UserState as Stream;
            if (e.Result != null)
                reward = e.Result;
            rewardbool = true;
            TryPageInit(ss);
        }
        #endregion
        /// <summary>
        /// 导出的样子就是导入的那个excel的样子
        /// </summary>
        public void PageInit(Stream stream)
        {
            XlsDocument xls = new XlsDocument();
            #region 人员基本信息
            XF xf = xls.NewXF();            
            xf.UseBorder = true;
            xf.TopLineStyle = 1;
            xf.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf.BottomLineStyle = 1;
            xf.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf.LeftLineStyle = 1;
            xf.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf.RightLineStyle = 1;
            xf.RightLineColor = org.in2bits.MyXls.Colors.Black;

            XF xf1 = xls.NewXF();
            xf1.UseBorder = true;
            xf1.TopLineStyle = 1;
            xf1.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.BottomLineStyle = 1;
            xf1.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.LeftLineStyle = 1;
            xf1.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.RightLineStyle = 1;
            xf1.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.HorizontalAlignment = HorizontalAlignments.Centered;
            xf1.VerticalAlignment = VerticalAlignments.Centered;
            xf1.Font.Bold = true;
            xf1.Font.Height = 12 * 20;
         

            Worksheet sheet = xls.Workbook.Worksheets.AddNamed("人员信息基本集");
            sheet.Cells.Add(1, 1, "编号", xf1);
            sheet.Cells.Add(1, 2, "姓名", xf1);
            sheet.Cells.Add(1, 3, "证件号码", xf1);
            sheet.Cells.Add(1, 4, "性别", xf1);
            sheet.Cells.Add(1, 5, "出生日期", xf1);
            sheet.Cells.Add(1, 6, "退休时间", xf1);
            sheet.Cells.Add(1, 7, "距离退休年限", xf1);
            sheet.Cells.Add(1, 8, "出生地", xf1);
            sheet.Cells.Add(1, 9, "籍贯", xf1);
            sheet.Cells.Add(1, 10, "民族", xf1);
            sheet.Cells.Add(1, 11, "政治面貌", xf1);
            sheet.Cells.Add(1, 12, "健康状况", xf1);
            sheet.Cells.Add(1, 13, "参加工作日期", xf1);
            sheet.Cells.Add(1, 14, "现工作单位", xf1);
            sheet.Cells.Add(1, 15, "现工作部门", xf1);
            sheet.Cells.Add(1, 16, "公务员登记号", xf1);
            sheet.Cells.Add(1, 17, "人员编制类型", xf1);
            sheet.Cells.Add(1, 18, "进本单位年月", xf1);
            sheet.Cells.Add(1, 19, "获本区公务员身份方式", xf1);
            sheet.Cells.Add(1, 20, "户籍所在地", xf1);
            sheet.Cells.Add(1, 21, "婚姻状况", xf1);
            sheet.Cells.Add(1, 22, "家庭住址", xf1);
            sheet.Cells.Add(1, 23, "住宅电话", xf1);
            sheet.Cells.Add(1, 24, "个人身份", xf1);
            sheet.Cells.Add(1, 25, "入党时间", xf1);
            sheet.Cells.Add(1, 26, "专长", xf1);
            sheet.Cells.Add(1, 27, "专业技术职务", xf1);
            sheet.Cells.Add(1, 28, "人员类别", xf1);
            sheet.Cells.Add(1, 29, "公务员登记时间", xf1);
            ColumnInfo colInfo = new ColumnInfo(xls, sheet);
            sheet.AddColumnInfo(colInfo);
            //证件号码
            ColumnInfo colInfo2 = new ColumnInfo(xls, sheet);
            colInfo2.Width = 20 * 256;
            colInfo2.ColumnIndexStart = 2;
            colInfo2.ColumnIndexEnd = 2;
            sheet.AddColumnInfo(colInfo2);
            //出生日期
            ColumnInfo colInfo4 = new ColumnInfo(xls, sheet);
            colInfo4.Width = 14 * 256;
            colInfo4.ColumnIndexStart = 4;
            colInfo4.ColumnIndexEnd = 4;
            sheet.AddColumnInfo(colInfo4);
            //退休时间
            ColumnInfo colInfo5 = new ColumnInfo(xls, sheet);
            colInfo5.Width = 14 * 256;
            colInfo5.ColumnIndexStart = 5;
            colInfo5.ColumnIndexEnd = 5;
            sheet.AddColumnInfo(colInfo5);
            //健康
            ColumnInfo colInfo9 = new ColumnInfo(xls, sheet);
            colInfo9.Width = 10 * 256;
            colInfo9.ColumnIndexStart = 11;
            colInfo9.ColumnIndexEnd = 11;
            sheet.AddColumnInfo(colInfo9);
            //参加工作日期
            ColumnInfo colInfo10 = new ColumnInfo(xls, sheet);
            colInfo10.Width = 15 * 256;
            colInfo10.ColumnIndexStart = 12;
            colInfo10.ColumnIndexEnd = 12;
            sheet.AddColumnInfo(colInfo10);
            //现工作单位
            ColumnInfo colInfo11 = new ColumnInfo(xls, sheet);
            colInfo11.Width = 50 * 256;
            colInfo11.ColumnIndexStart = 13;
            colInfo11.ColumnIndexEnd = 13;
            sheet.AddColumnInfo(colInfo11);
            //参加工作日期
            ColumnInfo colInfo12 = new ColumnInfo(xls, sheet);
            colInfo12.Width = 30 * 256;
            colInfo12.ColumnIndexStart = 14;
            colInfo12.ColumnIndexEnd = 14;
            sheet.AddColumnInfo(colInfo12);
            //填充内容  
            if (temp.Count > 0)
                for (int i = 0; i < temp.Count; i++)
                {
                    sheet.Cells.Add(i + 2, 1, i+1, xf);
                    if (temp[i].Name != null) sheet.Cells.Add(i + 2, 2, temp[i].Name.ToString(), xf);
                    if (temp[i].CardNo != null) sheet.Cells.Add(i + 2, 3, temp[i].CardNo.ToString(), xf);
                    if (temp[i].Gender != null) sheet.Cells.Add(i + 2, 4, temp[i].Gender.ToString(), xf);
                    if (temp[i].Birthday != null && Convert.ToDateTime(temp[i].Birthday).ToShortDateString() != "1900/1/1")
                    {
                        sheet.Cells.Add(i + 2, 5, Convert.ToDateTime(temp[i].Birthday).ToShortDateString(), xf);
                    }
                    if (temp[i].TuiXiuDate != null && Convert.ToDateTime(temp[i].TuiXiuDate).ToShortDateString() != "1900/1/1") sheet.Cells.Add(i + 2, 6, temp[i].TuiXiuDate.ToString(), xf);
                    if (temp[i].JuTuiXiuDate != null) sheet.Cells.Add(i + 2, 7, temp[i].JuTuiXiuDate.ToString(), xf);


                    if (temp[i].BirthPlace != null) sheet.Cells.Add(i + 2, 8, temp[i].BirthPlace.ToString(), xf);
                    if (temp[i].NativePlace != null) sheet.Cells.Add(i + 2, 9, temp[i].NativePlace.ToString(), xf);
                    if (temp[i].Native != null) sheet.Cells.Add(i + 2, 10, temp[i].Native.ToString(), xf);
                    if (temp[i].Political != null) sheet.Cells.Add(i + 2, 11, temp[i].Political.ToString(), xf);
                    if (temp[i].Health != null) sheet.Cells.Add(i + 2, 12, temp[i].Health.ToString(), xf);
                    if (temp[i].WorkDate != null && Convert.ToDateTime(temp[i].WorkDate).ToShortDateString() != "1900/1/1") sheet.Cells.Add(i + 2, 13, Convert.ToDateTime(temp[i].WorkDate).ToShortDateString(), xf);
                    if (temp[i].OrgName != null) sheet.Cells.Add(i + 2, 14, temp[i].OrgName.ToString(), xf);

                    if (temp[i].PositionName != null) sheet.Cells.Add(i + 2, 15, temp[i].PositionName.ToString(), xf);
                    if (temp[i].RegisterNo != null) sheet.Cells.Add(i + 2, 16, temp[i].RegisterNo.ToString(), xf);
                    if (temp[i].OrganizationType != null) sheet.Cells.Add(i + 2, 17, temp[i].OrganizationType.ToString(), xf);
                    if (temp[i].NowWorkDate != null && Convert.ToDateTime(temp[i].NowWorkDate).ToShortDateString() != "1900/1/1") sheet.Cells.Add(i + 2, 18, Convert.ToDateTime(temp[i].NowWorkDate).ToShortDateString(), xf);
                    if (temp[i].HouseholdRegister != null) sheet.Cells.Add(i + 2, 20, temp[i].HouseholdRegister.ToString(), xf);
                    if (temp[i].HuoDeFangShi != null) sheet.Cells.Add(i + 2, 19, temp[i].HuoDeFangShi.ToString(), xf);
                    if (temp[i].Marriage != null) sheet.Cells.Add(i + 2, 21, temp[i].Marriage.ToString(), xf);
                    if (temp[i].HomeAddress != null) sheet.Cells.Add(i + 2, 22, temp[i].HomeAddress.ToString(), xf);
                    if (temp[i].Phone != null) sheet.Cells.Add(i + 2, 23, temp[i].Phone.ToString(), xf);
                    if (temp[i].EmpIdentity != null) sheet.Cells.Add(i + 2, 24, temp[i].EmpIdentity.ToString(), xf);
                    if (temp[i].PartyTime != null && Convert.ToDateTime(temp[i].PartyTime).ToShortDateString() != "1900/1/1") sheet.Cells.Add(i + 2, 25, Convert.ToDateTime(temp[i].PartyTime).ToShortDateString(), xf);
                    if (temp[i].Special != null) sheet.Cells.Add(i + 2, 26, temp[i].Special.ToString(), xf);
                    if (temp[i].TechnicalPositions != null) sheet.Cells.Add(i + 2, 27, temp[i].TechnicalPositions.ToString(), xf);
                    if (temp[i].PersonnelType != null) sheet.Cells.Add(i + 2, 28, temp[i].PersonnelType.ToString(), xf);
                    if (temp[i].RegisterDate != null && Convert.ToDateTime(temp[i].RegisterDate).ToShortDateString() != "1900/1/1") sheet.Cells.Add(i + 2, 29, Convert.ToDateTime(temp[i].RegisterDate).ToShortDateString(), xf);
                }
            #endregion

            #region 学历信息子集
            Worksheet sheet1 = xls.Workbook.Worksheets.AddNamed("学历信息子集");
            sheet1.Cells.Add(1, 1, "姓名", xf1);
            sheet1.Cells.Add(1, 2, "证件号码", xf1);
            sheet1.Cells.Add(1, 3, "学历名称", xf1);
            sheet1.Cells.Add(1, 4, "学习形式", xf1);
            sheet1.Cells.Add(1, 5, "学制", xf1);
            sheet1.Cells.Add(1, 6, "毕（肄）业日期", xf1);
            sheet1.Cells.Add(1, 7, "学校", xf1);
            sheet1.Cells.Add(1, 8, "所学专业", xf1);
            sheet1.Cells.Add(1, 9, "是否最高学历", xf1);
            ColumnInfo colInfoxueli1 = new ColumnInfo(xls, sheet1);
            colInfoxueli1.Width = 20 * 256;
            colInfoxueli1.ColumnIndexStart = 1;
            colInfoxueli1.ColumnIndexEnd = 1;
            sheet1.AddColumnInfo(colInfoxueli1);
            ColumnInfo colInfoxueli3 = new ColumnInfo(xls, sheet1);
            colInfoxueli3.Width = 10 * 256;
            colInfoxueli3.ColumnIndexStart = 3;
            colInfoxueli3.ColumnIndexEnd = 3;
            sheet1.AddColumnInfo(colInfoxueli3);
            ColumnInfo colInfoxueli6 = new ColumnInfo(xls, sheet1);
            colInfoxueli6.Width = 30 * 256;
            colInfoxueli6.ColumnIndexStart = 6;
            colInfoxueli6.ColumnIndexEnd = 6;
            sheet1.AddColumnInfo(colInfoxueli6);
            ColumnInfo colInfoxueli7 = new ColumnInfo(xls, sheet1);
            colInfoxueli7.Width = 20 * 256;
            colInfoxueli7.ColumnIndexStart = 7;
            colInfoxueli7.ColumnIndexEnd = 7;
            sheet1.AddColumnInfo(colInfoxueli7);

            //填充内容    
            if (education.Count > 0)
                for (int i = 0; i < education.Count; i++)
                {
                    if (education[i].EmpName != null) sheet1.Cells.Add(i + 2, 1, education[i].EmpName.ToString(), xf);
                    if (education[i].EmpNo != null) sheet1.Cells.Add(i + 2, 2, education[i].EmpNo.ToString(), xf);
                    if (education[i].EducationName != null) sheet1.Cells.Add(i + 2, 3, education[i].EducationName.ToString(), xf);
                    if (education[i].EducationType != null) sheet1.Cells.Add(i + 2, 4, education[i].EducationType.ToString(), xf);
                    if (education[i].EducationaSystem != null) sheet1.Cells.Add(i + 2, 5, education[i].EducationaSystem.ToString(), xf);
                    if (education[i].GraduationDate != null && Convert.ToDateTime(education[i].GraduationDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet1.Cells.Add(i + 2, 6, Convert.ToDateTime(education[i].GraduationDate).ToShortDateString(), xf);
                    }
                    if (education[i].School != null) sheet1.Cells.Add(i + 2, 7, education[i].School.ToString(), xf);
                    if (education[i].Professional != null) sheet1.Cells.Add(i + 2, 8, education[i].Professional.ToString(), xf);
                    if (education[i].IsTopEducation == false) sheet1.Cells.Add(i + 2, 9, "否", xf); else sheet1.Cells.Add(i + 2, 9, "是", xf);

                }
            #endregion

            #region 学位信息子集
            Worksheet sheet2 = xls.Workbook.Worksheets.AddNamed("学位信息子集");
            sheet2.Cells.Add(1, 1, "姓名", xf1);
            sheet2.Cells.Add(1, 2, "证件号码", xf1);
            sheet2.Cells.Add(1, 3, "学位名称", xf1);
            sheet2.Cells.Add(1, 4, "学习形式", xf1);
            sheet2.Cells.Add(1, 5, "学制", xf1);
            sheet2.Cells.Add(1, 6, "毕（肄）业日期", xf1);
            sheet2.Cells.Add(1, 7, "学校", xf1);
            sheet2.Cells.Add(1, 8, "所学专业", xf1);
            ColumnInfo colInfoxuewei1 = new ColumnInfo(xls, sheet2);
            colInfoxuewei1.Width = 20 * 256;
            colInfoxuewei1.ColumnIndexStart = 1;
            colInfoxuewei1.ColumnIndexEnd = 1;
            sheet2.AddColumnInfo(colInfoxuewei1);
            ColumnInfo colInfoxuewei3 = new ColumnInfo(xls, sheet2);
            colInfoxuewei3.Width = 10 * 256;
            colInfoxuewei3.ColumnIndexStart = 3;
            colInfoxuewei3.ColumnIndexEnd = 3;
            sheet2.AddColumnInfo(colInfoxuewei3);
            ColumnInfo colInfoxuewei6 = new ColumnInfo(xls, sheet1);
            colInfoxuewei6.Width = 30 * 256;
            colInfoxuewei6.ColumnIndexStart = 6;
            colInfoxuewei6.ColumnIndexEnd = 6;
            sheet1.AddColumnInfo(colInfoxuewei6);
            ColumnInfo colInfoxuewei7 = new ColumnInfo(xls, sheet2);
            colInfoxuewei7.Width = 20 * 256;
            colInfoxuewei7.ColumnIndexStart = 7;
            colInfoxuewei7.ColumnIndexEnd = 7;
            sheet2.AddColumnInfo(colInfoxuewei7);

            //填充内容    
            if (degree.Count > 0)
                for (int i = 0; i < degree.Count; i++)
                {
                    if (degree[i].EmpName != null) sheet2.Cells.Add(i + 2, 1, degree[i].EmpName.ToString(), xf);
                    if (degree[i].EmpNo != null) sheet2.Cells.Add(i + 2, 2, degree[i].EmpNo.ToString(), xf);
                    if (degree[i].DegreeName != null) sheet2.Cells.Add(i + 2, 3, degree[i].DegreeName.ToString(), xf);
                    if (degree[i].LearningType != null) sheet2.Cells.Add(i + 2, 4, degree[i].LearningType.ToString(), xf);
                    if (degree[i].EducationalSystem != null) sheet2.Cells.Add(i + 2, 5, degree[i].EducationalSystem.ToString(), xf);
                    if (degree[i].EducationDate != null && Convert.ToDateTime(degree[i].EducationDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet2.Cells.Add(i + 2, 6, Convert.ToDateTime(degree[i].EducationDate).ToShortDateString(), xf);
                    }
                    if (degree[i].School != null) sheet2.Cells.Add(i + 2, 7, degree[i].School.ToString(), xf);
                    if (degree[i].Professional != null) sheet2.Cells.Add(i + 2, 8, degree[i].Professional.ToString(), xf);

                }
            #endregion

            #region 简历信息子集
            Worksheet sheet3 = xls.Workbook.Worksheets.AddNamed("简历信息子集");
            sheet3.Cells.Add(1, 1, "姓名", xf1);
            sheet3.Cells.Add(1, 2, "证件号码", xf1);
            sheet3.Cells.Add(1, 3, "开始日期", xf1);
            sheet3.Cells.Add(1, 4, "结束日期", xf1);
            sheet3.Cells.Add(1, 5, "所在单位", xf1);
            sheet3.Cells.Add(1, 6, "担任职务", xf1);
            sheet3.Cells.Add(1, 7, "证明人", xf1);
            sheet3.Cells.Add(1, 8, "是否为期间", xf1);
            ColumnInfo colInfojianli1 = new ColumnInfo(xls, sheet3);
            colInfojianli1.Width = 20 * 256;
            colInfojianli1.ColumnIndexStart = 1;
            colInfojianli1.ColumnIndexEnd = 1;
            sheet3.AddColumnInfo(colInfojianli1);
            ColumnInfo colInfojianli4 = new ColumnInfo(xls, sheet3);
            colInfojianli4.Width = 40 * 256;
            colInfojianli4.ColumnIndexStart = 4;
            colInfojianli4.ColumnIndexEnd = 4;
            sheet3.AddColumnInfo(colInfojianli4);
            ColumnInfo colInfojianli5 = new ColumnInfo(xls, sheet3);
            colInfojianli5.Width = 40 * 256;
            colInfojianli5.ColumnIndexStart = 5;
            colInfojianli5.ColumnIndexEnd = 5;
            sheet3.AddColumnInfo(colInfojianli5);
            //填充内容    
            if (resume.Count > 0)
                for (int i = 0; i < resume.Count; i++)
                {
                    if (resume[i].EmpName != null) sheet3.Cells.Add(i + 2, 1, resume[i].EmpName.ToString(), xf);
                    if (resume[i].EmpNo != null) sheet3.Cells.Add(i + 2, 2, resume[i].EmpNo.ToString(), xf);
                    if (resume[i].BeginDate != null && Convert.ToDateTime(resume[i].BeginDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet3.Cells.Add(i + 2, 3, Convert.ToDateTime(resume[i].BeginDate).ToShortDateString(), xf);
                    }
                    if (resume[i].EndDate != null && Convert.ToDateTime(resume[i].EndDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet3.Cells.Add(i + 2, 4, Convert.ToDateTime(resume[i].EndDate).ToShortDateString(), xf);
                    }
                    if (resume[i].Unit != null) sheet3.Cells.Add(i + 2, 5, resume[i].Unit.ToString(), xf);
                    if (resume[i].Duty != null) sheet3.Cells.Add(i + 2, 6, resume[i].Duty.ToString(), xf);
                    if (resume[i].Witness != null) sheet3.Cells.Add(i + 2, 7, resume[i].Witness.ToString(), xf); else sheet3.Cells.Add(i + 2, 7, "", xf);
                    if (resume[i].IsPeriod == false) sheet3.Cells.Add(i + 2, 8, "否", xf); else sheet3.Cells.Add(i + 2, 8, "是", xf);
                }
            #endregion

            #region 职务信息子集
            Worksheet sheet4 = xls.Workbook.Worksheets.AddNamed("职务信息子集");
            sheet4.Cells.Add(1, 1, "姓名", xf1);
            sheet4.Cells.Add(1, 2, "证件号码", xf1);
            sheet4.Cells.Add(1, 3, "职务代码", xf1);
            sheet4.Cells.Add(1, 4, "职务名称", xf1);
            sheet4.Cells.Add(1, 5, "职务层次", xf1);
            sheet4.Cells.Add(1, 6, "任现职务层次时间", xf1);
            sheet4.Cells.Add(1, 7, "职务属性", xf1);
            sheet4.Cells.Add(1, 8, "任现职务属性时间", xf1);
            sheet4.Cells.Add(1, 9, "批准时间", xf1);
            sheet4.Cells.Add(1, 10, "任职机构名称", xf1);

            sheet4.Cells.Add(1, 11, "集体内排序号", xf1);
            sheet4.Cells.Add(1, 12, "分管（从事）工作", xf1);
            sheet4.Cells.Add(1, 13, "任职方式", xf1);
            sheet4.Cells.Add(1, 14, "是否破格提拔", xf1);
            sheet4.Cells.Add(1, 15, "任职状态", xf1);

            ColumnInfo colInfozhiwu1 = new ColumnInfo(xls, sheet4);
            colInfozhiwu1.Width = 20 * 256;
            colInfozhiwu1.ColumnIndexStart = 1;
            colInfozhiwu1.ColumnIndexEnd = 1;
            sheet4.AddColumnInfo(colInfozhiwu1);
            ColumnInfo colInfozhiwu3 = new ColumnInfo(xls, sheet1);
            colInfozhiwu3.Width = 30 * 256;
            colInfozhiwu3.ColumnIndexStart = 3;
            colInfozhiwu3.ColumnIndexEnd = 3;
            sheet1.AddColumnInfo(colInfozhiwu3);
            ColumnInfo colInfozhiwu4 = new ColumnInfo(xls, sheet4);
            colInfozhiwu4.Width = 20 * 256;
            colInfozhiwu4.ColumnIndexStart = 4;
            colInfozhiwu4.ColumnIndexEnd = 4;
            sheet4.AddColumnInfo(colInfozhiwu4);
            ColumnInfo colInfozhiwu8 = new ColumnInfo(xls, sheet4);
            colInfozhiwu8.Width = 40 * 256;
            colInfozhiwu8.ColumnIndexStart = 9;
            colInfozhiwu8.ColumnIndexEnd = 9;
            sheet4.AddColumnInfo(colInfozhiwu8);
            ColumnInfo colInfozhiwu9 = new ColumnInfo(xls, sheet4);
            colInfozhiwu9.Width = 30 * 256;
            colInfozhiwu9.ColumnIndexStart =11;
            colInfozhiwu9.ColumnIndexEnd = 11;
            sheet4.AddColumnInfo(colInfozhiwu9);
            ColumnInfo colInfozhiwu5 = new ColumnInfo(xls, sheet4);
            colInfozhiwu5.Width = 14 * 256;
            colInfozhiwu5.ColumnIndexStart = 5;
            colInfozhiwu5.ColumnIndexEnd = 5;
            sheet4.AddColumnInfo(colInfozhiwu5);
            ColumnInfo colInfozhiwu7 = new ColumnInfo(xls, sheet4);
            colInfozhiwu7.Width = 14 * 256;
            colInfozhiwu7.ColumnIndexStart = 7;
            colInfozhiwu7.ColumnIndexEnd = 7;
            sheet4.AddColumnInfo(colInfozhiwu7);

            //填充内容     
            if (duty.Count > 0)
                for (int i = 0; i < duty.Count; i++)
                {
                    if (duty[i].EmpName != null) sheet4.Cells.Add(i + 2, 1, duty[i].EmpName.ToString(), xf);
                    if (duty[i].EmpNo != null) sheet4.Cells.Add(i + 2, 2, duty[i].EmpNo.ToString(), xf);
                    if (duty[i].DutyNo != null) sheet4.Cells.Add(i + 2, 3, duty[i].DutyNo.ToString(), xf);
                    if (duty[i].DutyName != null) sheet4.Cells.Add(i + 2, 4, duty[i].DutyName.ToString(), xf);
                    if (duty[i].DutyLevel != null) sheet4.Cells.Add(i + 2, 5, duty[i].DutyLevel.ToString(), xf);
                    if (duty[i].JobDate != null && Convert.ToDateTime(duty[i].JobDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet4.Cells.Add(i + 2, 6, Convert.ToDateTime(duty[i].JobDate).ToShortDateString(), xf);
                    }
                    if (duty[i].DutyAttribute != null) sheet4.Cells.Add(i + 2, 7, duty[i].DutyAttribute.ToString(), xf);
                    if (duty[i].RXRZWSXSJ != null && Convert.ToDateTime(duty[i].RXRZWSXSJ).ToShortDateString() != "1900/1/1")
                    {
                        sheet4.Cells.Add(i + 2, 8, Convert.ToDateTime(duty[i].RXRZWSXSJ).ToShortDateString(), xf);
                    }
                    if (duty[i].OKDate != null && Convert.ToDateTime(duty[i].OKDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet4.Cells.Add(i + 2, 9, Convert.ToDateTime(duty[i].OKDate).ToShortDateString(), xf);
                    }
                    if (duty[i].OrganizationName != null) sheet4.Cells.Add(i + 2, 10, duty[i].OrganizationName.ToString(), xf);
                    if (duty[i].Sec != null) sheet4.Cells.Add(i + 2, 11, duty[i].Sec.ToString(), xf);
                    if (duty[i].WorkCharge != null) sheet4.Cells.Add(i + 2, 12, duty[i].WorkCharge.ToString(), xf);
                    if (duty[i].ServiceMode != null) sheet4.Cells.Add(i + 2, 13, duty[i].ServiceMode.ToString(), xf);
                    if (duty[i].IsExceptionalPromotion != null) sheet4.Cells.Add(i + 2, 14, duty[i].IsExceptionalPromotion.ToString(), xf);
                    if (duty[i].JobStatus != null) sheet4.Cells.Add(i + 2, 15, duty[i].JobStatus.ToString(), xf);
                    
                }
            #endregion

            #region 奖惩信息子集
            Worksheet sheet5 = xls.Workbook.Worksheets.AddNamed("奖励情况信息子集");
            sheet5.Cells.Add(1, 1, "姓名", xf1);
            sheet5.Cells.Add(1, 2, "证件号码", xf1);
            sheet5.Cells.Add(1, 3, "奖惩代码", xf1);
            sheet5.Cells.Add(1, 4, "奖惩名称", xf1);
            sheet5.Cells.Add(1, 5, "奖惩原因", xf1);
            sheet5.Cells.Add(1, 6, "其他奖惩原因", xf1);
            sheet5.Cells.Add(1, 7, "批准日期", xf1);
            sheet5.Cells.Add(1, 8, "批准机关名称", xf1);
            ColumnInfo colInfojiangcheng1 = new ColumnInfo(xls, sheet5);
            colInfojiangcheng1.Width = 20 * 256;
            colInfojiangcheng1.ColumnIndexStart = 1;
            colInfojiangcheng1.ColumnIndexEnd = 1;
            sheet5.AddColumnInfo(colInfojiangcheng1);
            ColumnInfo colInfojiangcheng3 = new ColumnInfo(xls, sheet5);
            colInfojiangcheng3.Width = 20 * 256;
            colInfojiangcheng3.ColumnIndexStart = 3;
            colInfojiangcheng3.ColumnIndexEnd = 3;
            sheet5.AddColumnInfo(colInfojiangcheng3);
            ColumnInfo colInfojiangcheng4 = new ColumnInfo(xls, sheet5);
            colInfojiangcheng4.Width = 80 * 256;
            colInfojiangcheng4.ColumnIndexStart = 4;
            colInfojiangcheng4.ColumnIndexEnd = 4;
            sheet5.AddColumnInfo(colInfojiangcheng4);
            ColumnInfo colInfojiangcheng5 = new ColumnInfo(xls, sheet5);
            colInfojiangcheng5.Width = 20 * 256;
            colInfojiangcheng5.ColumnIndexStart = 5;
            colInfojiangcheng5.ColumnIndexEnd = 5;
            sheet5.AddColumnInfo(colInfojiangcheng5);
            ColumnInfo colInfojiangcheng7 = new ColumnInfo(xls, sheet5);
            colInfojiangcheng7.Width = 30 * 256;
            colInfojiangcheng7.ColumnIndexStart = 7;
            colInfojiangcheng7.ColumnIndexEnd = 7;
            sheet5.AddColumnInfo(colInfojiangcheng7);

            //填充内容  
            if (reward.Count > 0)
                for (int i = 0; i < reward.Count; i++)
                {
                    if (reward[i].EmpName != null) sheet5.Cells.Add(i + 2, 1, reward[i].EmpName.ToString(), xf);
                    if (reward[i].EmpNo != null) sheet5.Cells.Add(i + 2, 2, reward[i].EmpNo.ToString(), xf);
                    if (reward[i].RewardNo != null) sheet5.Cells.Add(i + 2, 3, reward[i].RewardNo.ToString(), xf);
                    if (reward[i].RewardName != null) sheet5.Cells.Add(i + 2, 4, reward[i].RewardName.ToString(), xf);
                    if (reward[i].RewardReason != null) sheet5.Cells.Add(i + 2, 5, reward[i].RewardReason.ToString(), xf);
                    if (reward[i].OtherRewardReason != null) sheet5.Cells.Add(i + 2, 6, reward[i].OtherRewardReason.ToString(), xf);
                    if (reward[i].OKDate != null && Convert.ToDateTime(reward[i].OKDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet5.Cells.Add(i + 2, 7, Convert.ToDateTime(reward[i].OKDate).ToShortDateString(), xf);
                    }
                    if (reward[i].OKUnit != null) sheet5.Cells.Add(i + 2, 8, reward[i].OKUnit.ToString(), xf);

                }
            #endregion

            #region 处分情况信息子集
            Worksheet sheet6 = xls.Workbook.Worksheets.AddNamed("处分情况信息子集");
            sheet6.Cells.Add(1, 1, "姓名", xf1);
            sheet6.Cells.Add(1, 2, "证件号码", xf1);
            sheet6.Cells.Add(1, 3, "处分代码", xf1);
            sheet6.Cells.Add(1, 4, "处分名称", xf1);
            sheet6.Cells.Add(1, 5, "处分原因", xf1);
            sheet6.Cells.Add(1, 6, "处分批准机关名称", xf1);
            sheet6.Cells.Add(1, 7, "处分批准日期", xf1);
            sheet6.Cells.Add(1, 8, "处分期限", xf1);
            ColumnInfo colInfochufen1 = new ColumnInfo(xls, sheet6);
            colInfochufen1.Width = 20 * 256;
            colInfochufen1.ColumnIndexStart = 1;
            colInfochufen1.ColumnIndexEnd = 1;
            sheet6.AddColumnInfo(colInfochufen1);
            ColumnInfo colInfochufen2 = new ColumnInfo(xls, sheet6);
            colInfochufen2.Width = 20 * 256;
            colInfochufen2.ColumnIndexStart = 2;
            colInfochufen2.ColumnIndexEnd = 2;
            sheet6.AddColumnInfo(colInfochufen1);
            ColumnInfo colInfochufen3 = new ColumnInfo(xls, sheet6);
            colInfochufen3.Width = 20 * 256;
            colInfochufen3.ColumnIndexStart = 3;
            colInfochufen3.ColumnIndexEnd = 3;
            sheet6.AddColumnInfo(colInfochufen3);
            ColumnInfo colInfochufen4 = new ColumnInfo(xls, sheet6);
            colInfochufen4.Width = 60 * 256;
            colInfochufen4.ColumnIndexStart = 4;
            colInfochufen4.ColumnIndexEnd = 4;
            sheet6.AddColumnInfo(colInfochufen4);
            ColumnInfo colInfochufen5 = new ColumnInfo(xls, sheet6);
            colInfochufen5.Width = 30 * 256;
            colInfochufen5.ColumnIndexStart = 5;
            colInfochufen5.ColumnIndexEnd = 5;
            sheet6.AddColumnInfo(colInfochufen5);

            //填充内容 
            if (punish.Count > 0)
                for (int i = 0; i < punish.Count; i++)
                {
                    if (punish[i].EmpName != null) sheet6.Cells.Add(i + 2, 1, punish[i].EmpName.ToString(), xf);
                    if (punish[i].EmpNo != null) sheet6.Cells.Add(i + 2, 2, punish[i].EmpNo.ToString(), xf);
                    if (punish[i].PunishmentNo != null) sheet6.Cells.Add(i + 2, 3, punish[i].PunishmentNo.ToString(), xf);
                    if (punish[i].PunishmentName != null) sheet6.Cells.Add(i + 2, 4, punish[i].PunishmentName.ToString(), xf);
                    if (punish[i].PunishmentReason != null) sheet6.Cells.Add(i + 2, 5, punish[i].PunishmentReason.ToString(), xf);
                    if (punish[i].OkUnit != null) sheet6.Cells.Add(i + 2, 6, punish[i].OkUnit.ToString(), xf);
                    if (punish[i].OKDate != null && Convert.ToDateTime(punish[i].OKDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet6.Cells.Add(i + 2, 7, Convert.ToDateTime(punish[i].OKDate).ToShortDateString(), xf);
                    }
                    if (punish[i].PunishmentTimeLimit != null) sheet6.Cells.Add(i + 2, 8, punish[i].PunishmentTimeLimit.ToString(), xf);

                }
            #endregion

            #region 考核信息子集
            Worksheet sheet7 = xls.Workbook.Worksheets.AddNamed("考核情况信息子集");
            sheet7.Cells.Add(1, 1, "姓名", xf1);
            sheet7.Cells.Add(1, 2, "证件号码", xf1);
            sheet7.Cells.Add(1, 3, "考核类别", xf1);
            sheet7.Cells.Add(1, 4, "考核结果", xf1);
            sheet7.Cells.Add(1, 5, "考核时间", xf1);
            ColumnInfo colInfokaohe1 = new ColumnInfo(xls, sheet7);
            colInfokaohe1.Width = 20 * 256;
            colInfokaohe1.ColumnIndexStart = 1;
            colInfokaohe1.ColumnIndexEnd = 1;
            sheet7.AddColumnInfo(colInfokaohe1);

            //填充内容      
            if (empassessment.Count > 0)
                for (int i = 0; i < empassessment.Count; i++)
                {
                    if (empassessment[i].EmpName != null) sheet7.Cells.Add(i + 2, 1, empassessment[i].EmpName.ToString(), xf);
                    if (empassessment[i].EmpNo != null) sheet7.Cells.Add(i + 2, 2, empassessment[i].EmpNo.ToString(), xf);
                    if (empassessment[i].AssessmentType != null) sheet7.Cells.Add(i + 2, 3, empassessment[i].AssessmentType.ToString(), xf);
                    if (empassessment[i].AssessmentResult != null) sheet7.Cells.Add(i + 2, 4, empassessment[i].AssessmentResult.ToString(), xf);
                    if (empassessment[i].AssessmentDate != null && Convert.ToDateTime(empassessment[i].AssessmentDate).ToShortDateString() != "1900/1/1")
                    {
                        sheet7.Cells.Add(i + 2, 5, Convert.ToDateTime(empassessment[i].AssessmentDate).ToShortDateString(), xf);
                    }

                }
            #endregion

            #region 家庭关系信息子集
            Worksheet sheet8 = xls.Workbook.Worksheets.AddNamed("家庭关系信息子集");
            sheet8.Cells.Add(1, 1, "姓名", xf1);
            sheet8.Cells.Add(1, 2, "证件号码", xf1);
            sheet8.Cells.Add(1, 3, "人员姓名", xf1);
            sheet8.Cells.Add(1, 4, "称谓", xf1);
            sheet8.Cells.Add(1, 5, "所在单位", xf1);
            sheet8.Cells.Add(1, 6, "职务", xf1);
            sheet8.Cells.Add(1, 7, "政治面貌", xf1);
            sheet8.Cells.Add(1, 8, "出生日期", xf1);
            ColumnInfo colInfojiating1 = new ColumnInfo(xls, sheet8);
            colInfojiating1.Width = 20 * 256;
            colInfojiating1.ColumnIndexStart = 1;
            colInfojiating1.ColumnIndexEnd = 1;
            sheet8.AddColumnInfo(colInfojiating1);
            ColumnInfo colInfojiating4 = new ColumnInfo(xls, sheet8);
            colInfojiating4.Width = 40 * 256;
            colInfojiating4.ColumnIndexStart = 4;
            colInfojiating4.ColumnIndexEnd = 4;
            sheet8.AddColumnInfo(colInfojiating1);
            ColumnInfo colInfojiating5 = new ColumnInfo(xls, sheet8);
            colInfojiating5.Width = 30 * 256;
            colInfojiating5.ColumnIndexStart = 5;
            colInfojiating5.ColumnIndexEnd = 5;
            sheet8.AddColumnInfo(colInfojiating5);

            //填充内容   
            if (family.Count > 0)
                for (int i = 0; i < family.Count; i++)
                {
                    if (family[i].EmpName != null) sheet8.Cells.Add(i + 2, 1, family[i].EmpName.ToString(), xf);
                    if (family[i].EmpNo != null) sheet8.Cells.Add(i + 2, 2, family[i].EmpNo.ToString(), xf);
                    if (family[i].Name != null) sheet8.Cells.Add(i + 2, 3, family[i].Name.ToString(), xf);
                    if (family[i].Appellation != null) sheet8.Cells.Add(i + 2, 4, family[i].Appellation.ToString(), xf);
                    if (family[i].Unit != null) sheet8.Cells.Add(i + 2, 5, family[i].Unit.ToString(), xf);
                    if (family[i].Duty != null) sheet8.Cells.Add(i + 2, 6, family[i].Duty.ToString(), xf);
                    if (family[i].Political != null) sheet8.Cells.Add(i + 2, 7, family[i].Political.ToString(), xf);
                    if (family[i].Birthday != null && Convert.ToDateTime(family[i].Birthday).ToShortDateString() != "1900/1/1")
                    {
                        sheet8.Cells.Add(i + 2, 8, Convert.ToDateTime(family[i].Birthday).ToShortDateString(), xf);
                    }

                }
            #endregion
            ss = null;
            DataSheetExport = null;
            xls.Save(stream);
            stream.Close();
            stream.Dispose();
            SilverlightMessageBoxLibrary.Message.InfoMessage("导出成功");
        }
        #endregion
        /// <summary>
        /// 保证每个列表都查询到了
        /// </summary> 
        private void TryPageInit(Stream stream)
        {
            if (empassessmentbool == true && degreebool == true
                && dutybool == true && educationbool == true
                && familybool == true && punishbool == true
                && resumebool == true && rewardbool == true)
            {
                if (ss == null && DataSheetExport != null)
                    stream = DataSheetExport;
                else if (DataSheetExport == null && ss != null)
                    stream = ss;
                if (KaiGuan == 0)//导出人员信息表
                    PageInit(stream);
                if (KaiGuan == 1)//导出个人信息表
                    PageInit1();
                empassessmentbool = false;
                degreebool = false;
                dutybool = false;
                educationbool = false;
                familybool = false;
                punishbool = false;
                resumebool = false;
                rewardbool = false;
            }
        }
        #region 个人信息表导出
        private Stream ExportPersonnelInfo = null;
        private void btnGeRenOut_Click(object sender, RoutedEventArgs e)
        {
            KaiGuan = 1;
            //var ss = DGRole.GetSelectedItems<EmpbasicService.Emp_BasicInfoModel>();
            if (DGRole.ItemsSource != null)
            {
                foreach (EmpbasicService.Emp_BasicInfoModel i in (ObservableCollection<EmpbasicService.Emp_BasicInfoModel>)DGRole.ItemsSource)
                {
                    if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(i);
                    }
                    if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                    }
                }
            }
            if (selectedempmodel.Count <= 0)
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择要导出的数据！");
                return;
            }
            if (selectedempmodel.Count > 1)
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("只能选择一个人员进行数据导出！");
                return;
            }
            var downLoad = new SaveFileDialog()
                                   {
                                       //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls",
                                       Filter = "Excel files(2003) (*.xls)|*.xls",

                                   };
            if (downLoad.ShowDialog() == true)
            {
                ExportPersonnelInfo = downLoad.OpenFile();
               // PageInit1();

                EmpbasicService.Emp_BasicInfoModel selectedItem = DGRole.SelectedItem as EmpbasicService.Emp_BasicInfoModel;
                List<byte> content = new List<byte>();
                string username = Session.LoginUser.LoginName;
                Client.GetPersonnelInfoExcelAsync(selectedItem.ID, username, content);
                
               

                //Client.GetEmp_AssessmentModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_AssessmentModelCompletedEventArgs>(
                //        Client_GetEmp_AssessmentModelCompleted);
                //Client.GetEmp_AssessmentModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_DegreeModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_DegreeModelCompletedEventArgs>(
                //        Client_GetEmp_DegreeModelCompleted);
                //Client.GetEmp_DegreeModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_DutysCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_DutysCompletedEventArgs>(Client_GetEmp_DutysCompleted);
                //Client.GetEmp_DutysAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_EducationModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_EducationModelCompletedEventArgs>(
                //        Client_GetEmp_EducationModelCompleted);
                //Client.GetEmp_EducationModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_FamilyRelationModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_FamilyRelationModelCompletedEventArgs>(
                //        Client_GetEmp_FamilyRelationModelCompleted);
                //Client.GetEmp_FamilyRelationModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_PunishmentModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_PunishmentModelCompletedEventArgs>(
                //        Client_GetEmp_PunishmentModelCompleted);
                //Client.GetEmp_PunishmentModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_ResumeCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_ResumeCompletedEventArgs>(Client_GetEmp_ResumeCompleted);
                //Client.GetEmp_ResumeAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

                //Client.GetEmp_RewardInfoModelCompleted +=
                //    new EventHandler<EmpbasicService.GetEmp_RewardInfoModelCompletedEventArgs>(
                //        Client_GetEmp_RewardInfoModelCompleted);
                //Client.GetEmp_RewardInfoModelAsync("(" + selectedempmodel[0].ID.ToString() + ")", 0, ss);

            }
        }

        void Client_GetPersonnelInfoExcelCompleted(object sender, GetPersonnelInfoExcelCompletedEventArgs e)
        {
            EmpbasicService.Emp_BasicInfoModel selectedItem = DGRole.SelectedItem as EmpbasicService.Emp_BasicInfoModel;
            List<byte> content = e.UserState as List<byte>;
            CommunitySystem.EmpbasicService.FileTransferStream fff = e.Result;
            if (fff.IsFinished == false)
            {
                content.AddRange(fff.FileContent);
                string username = Session.LoginUser.LoginName;
                Client.GetPersonnelInfoExcelAsync(selectedItem.ID, username, content);                
            }
            else
            {
                content.AddRange(fff.FileContent);
                byte[] bytes = content.ToArray();
                ExportPersonnelInfo.Write(bytes, 0, bytes.Length);
                ExportPersonnelInfo.Close();
                ExportPersonnelInfo.Dispose();
                SilverlightMessageBoxLibrary.Message.InfoMessage("保存成功!");
            }
        }
        public void PageInit1()
        {
            //using (MemoryStream ms = new MemoryStream(Resource1.Book1))
            //{
            //    XlsDocument doc = new XlsDocument(ms);


            //    //DrawTemplete(doc);
            //    doc.Save(ss);
            //    ss.Close();
            //    ss.Dispose();
            //}
        }

        private Worksheet DrawTemplete(XlsDocument doc)
        {
            Worksheet sheet = doc.Workbook.Worksheets.AddNamed("Sheet1");
            //ColumnInfo ci = new ColumnInfo(doc, sheet);
            //ci.ColumnIndexStart = 5;
            //ci.ColumnIndexEnd = 5;
            //ci.Width = 1;
            //ci.Hidden = true;
            //sheet.AddColumnInfo(ci);

            sheet.Cells.Merge(1, 3, 3, 16);
            XF xf1 = doc.NewXF();
            xf1.HorizontalAlignment = HorizontalAlignments.CenteredAcrossSelection;
            xf1.VerticalAlignment = VerticalAlignments.Centered;
            xf1.Font.Height = 30;
            sheet.Cells.Add(1, 1, "人员信息表", xf1);

            sheet.Cells.Merge(4, 5, 3, 4);
            XF xf2 = doc.NewXF();
            xf2.HorizontalAlignment = HorizontalAlignments.CenteredAcrossSelection;
            xf2.VerticalAlignment = VerticalAlignments.Centered;
            xf2.Font.Height = 20;
            xf2.UseBorder = true;
            xf2.TopLineStyle = 1;
            xf2.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.BottomLineStyle = 1;
            xf2.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.LeftLineStyle = 1;
            xf2.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf2.RightLineStyle = 1;
            xf2.RightLineColor = org.in2bits.MyXls.Colors.Black;
            sheet.Cells.Add(3, 3, "姓 名", xf2);


            ///合并单元格
            //sheet.Cells.Merge(1, 4, 1, 5);
            //XF xf1 = doc.NewXF();
            //xf1.HorizontalAlignment = HorizontalAlignments.CenteredAcrossSelection;
            //xf1.VerticalAlignment = VerticalAlignments.Centered;
            //sheet.Cells.Add(1, 1, "test", xf1);

            //XF xf = doc.NewXF();
            //xf.HorizontalAlignment = HorizontalAlignments.Centered;
            //xf.VerticalAlignment = VerticalAlignments.Centered;

            //xf.UseBorder = true;
            //xf.TopLineStyle = 1;
            //xf.TopLineColor = org.in2bits.MyXls.Colors.Black;
            //xf.BottomLineStyle = 1;
            //xf.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            //xf.LeftLineStyle = 1;
            //xf.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            //xf.RightLineStyle = 1;
            //xf.RightLineColor = org.in2bits.MyXls.Colors.Black;

            //sheet.Cells.Add(8, 9, "tollin", xf);
            return sheet;
        }

        #endregion

        #region 导入人员信息
        private ObservableCollection<EmpbasicService.Emp_BasicInfoModel> InEmpBasicModels =
            new ObservableCollection<EmpbasicService.Emp_BasicInfoModel>();

        private ObservableCollection<EmpbasicService.Emp_EducationModel> InEmpEducation =
            new ObservableCollection<EmpbasicService.Emp_EducationModel>();

        private ObservableCollection<EmpbasicService.Emp_DegreeModel> InEmpDegree =
            new ObservableCollection<EmpbasicService.Emp_DegreeModel>();

        private ObservableCollection<EmpbasicService.Emp_ResumeModel> InEmpResume =
            new ObservableCollection<EmpbasicService.Emp_ResumeModel>();

        private ObservableCollection<EmpbasicService.Emp_Duty> InEmpDuty =
            new ObservableCollection<EmpbasicService.Emp_Duty>();

        private ObservableCollection<EmpbasicService.Emp_RewardInfoModel> InEmpReward =
            new ObservableCollection<EmpbasicService.Emp_RewardInfoModel>();

        private ObservableCollection<EmpbasicService.Emp_PunishmentModel> InEmpPunish =
            new ObservableCollection<EmpbasicService.Emp_PunishmentModel>();

        private ObservableCollection<EmpbasicService.Emp_AssessmentModel> InEmpAssenssment =
            new ObservableCollection<EmpbasicService.Emp_AssessmentModel>();

        private ObservableCollection<EmpbasicService.Emp_FamilyRelationModel> InEmpFamily =
            new ObservableCollection<EmpbasicService.Emp_FamilyRelationModel>();




        /// <summary>
        /// 判断用户输入是否为日期
        /// </summary>
        /// <param name="strValue"></param>
        /// <returns></returns>
        /// <remarks>
        /// 可判断格式如下（其中-可替换为/，不影响验证)
        /// YYYY | YYYY-MM | YYYY-MM-DD | YYYY-MM-DD HH:MM:SS | YYYY-MM-DD HH:MM:SS.FFF
        /// </remarks>
        public static bool IsDateTime(string strValue)
        {
            if (null == strValue)
            {
                return false;
            }

            string regexDate = @"[1-2]{1}[0-9]{3}((-|\/){1}(([0]?[1-9]{1})|(1[0-2]{1}))((-|\/){1}((([0]?[1-9]{1})|([1-2]{1}[0-9]{1})|(3[0-1]{1})))( (([0-1]{1}[0-9]{1})|2[0-3]{1}):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})(\.[0-9]{3})?)?)?)?$";

            if (Regex.IsMatch(strValue, regexDate))
            {
                //以下各月份日期验证，保证验证的完整性
                int _IndexY = -1;
                int _IndexM = -1;
                int _IndexD = -1;

                if (-1 != (_IndexY = strValue.IndexOf("-")))
                {
                    _IndexM = strValue.IndexOf("-", _IndexY + 1);
                    _IndexD = strValue.IndexOf(":");
                }
                else
                {
                    _IndexY = strValue.IndexOf("/");
                    _IndexM = strValue.IndexOf("/", _IndexY + 1);
                    _IndexD = strValue.IndexOf(":");
                }

                //不包含日期部分，直接返回true
                if (-1 == _IndexM)
                    return true;

                if (-1 == _IndexD)
                {
                    _IndexD = strValue.Length + 3;
                }

                int iYear = Convert.ToInt32(strValue.Substring(0, _IndexY));
                int iMonth = Convert.ToInt32(strValue.Substring(_IndexY + 1, _IndexM - _IndexY - 1));
                int iDate = Convert.ToInt32(strValue.Substring(_IndexM + 1, _IndexD - _IndexM - 4));

                //判断月份日期
                if ((iMonth < 8 && 1 == iMonth % 2) || (iMonth > 8 && 0 == iMonth % 2))
                {
                    if (iDate < 32)
                        return true;
                }
                else
                {
                    if (iMonth != 2)
                    {
                        if (iDate < 31)
                            return true;
                    }
                    else
                    {
                        //闰年
                        if ((0 == iYear % 400) || (0 == iYear % 4 && 0 < iYear % 100))
                        {
                            if (iDate < 30)
                                return true;
                        }
                        else
                        {
                            if (iDate < 29)
                                return true;
                        }
                    }
                }
            }

            return false;
        }
        private void btnIn_Click(object sender, RoutedEventArgs e)
        {
            InEmpBasicModels.Clear();
            InEmpEducation.Clear();
            InEmpDegree.Clear();
            InEmpResume.Clear();
            InEmpDuty.Clear();
            InEmpReward.Clear();
            InEmpPunish.Clear();
            InEmpAssenssment.Clear();
            InEmpFamily.Clear();
            try
            {
                OpenFileDialog dialog = new OpenFileDialog()
                                            {
                                                //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls", //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                                                Filter = "Excel files(2003) (*.xls)|*.xls",
                                                //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                                                Multiselect = false

                                            };
                if ((bool)dialog.ShowDialog())
                {
                    Stream stream = dialog.File.OpenRead();
                    XlsDocument doc = new XlsDocument(stream);
                    #region 人员基本信息
                    Worksheet sheet = doc.Workbook.Worksheets[0];
                    for (ushort i = 2; i <= sheet.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_BasicInfoModel tem = new EmpbasicService.Emp_BasicInfoModel();
                        tem.Name =
                            tem.CardNo =
                            tem.BirthPlace =
                            tem.HouseholdRegister = tem.Gender = tem.Native = tem.Political = tem.Health =
                                                                                              tem.RegisterNo =
                                                                                              tem.OrganizationType =
                                                                                              tem.NativePlace =
                                                                                              tem.Marriage =
                                                                                              tem.HomeAddress =
                                                                                              tem.Phone =
                                                                                              tem.EmpIdentity =
                                                                                              tem.Special =
                                                                                              tem.TechnicalPositions =
                                                                                              tem.PersonnelType =
                                                                                              tem.PositionName = "";
                        tem.OrgID = 0;
                        tem.WorkDate = tem.NowWorkDate = tem.PartyTime = tem.RegisterDate = tem.Birthday = null;
                        tem.Sequence = i - 1;
                        for (ushort ii = 1; ii <= sheet.Rows[i].CellCount; ii++)
                        {
                            int column = sheet.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 2:
                                    tem.Name = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.CardNo = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.Gender = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()))
                                            tem.Birthday = Convert.ToDateTime((DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()));
                                    }
                                    break;
                                case 6:
                                    tem.BirthPlace = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    tem.NativePlace = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    tem.Native = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 9:
                                    tem.Political = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 10:
                                    tem.Health = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 11:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()))
                                            tem.WorkDate = Convert.ToDateTime((DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()));
                                    }
                                    break;
                                case 12:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        tem.OrgID =
                                            OrgList.Where(p => p.Name == sheet.Rows[i].GetCell(ii).Value.ToString()).
                                                FirstOrDefault() == null
                                                ? 0
                                                : OrgList.Where(
                                                    p => p.Name == sheet.Rows[i].GetCell(ii).Value.ToString()).
                                                      FirstOrDefault().ID;
                                    }

                                    break;
                                case 13:
                                    tem.PositionName = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 14:
                                    tem.RegisterNo = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 15:
                                    tem.OrganizationType = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 16:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()))
                                            tem.NowWorkDate = Convert.ToDateTime((DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()));
                                    }
                                    break;
                                case 17:
                                    tem.HouseholdRegister = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 18:
                                    tem.Marriage = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 19:
                                    tem.HomeAddress = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 20:
                                    tem.Phone = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 21:
                                    tem.EmpIdentity = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 22:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()))
                                            tem.PartyTime = Convert.ToDateTime((DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()));
                                    }
                                    break;
                                case 23:
                                    tem.Special = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 24:
                                    tem.TechnicalPositions = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 25:
                                    tem.PersonnelType = sheet.Rows[i].GetCell(ii).Value == null ? null : sheet.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 26:
                                    if (sheet.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()))
                                            tem.RegisterDate = Convert.ToDateTime((DateTime.FromOADate(Convert.ToDouble(sheet.Rows[i].GetCell(ii).Value)).ToShortDateString()));
                                    }
                                    break;
                            }
                        }
                        InEmpBasicModels.Add(tem);
                    }
                    #endregion

                    #region 学历信息
                    Worksheet sheet1 = doc.Workbook.Worksheets[1];
                    for (ushort i = 2; i <= sheet1.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_EducationModel tem = new EmpbasicService.Emp_EducationModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.EducationName =
                            tem.EducationType = tem.EducationaSystem = tem.School = tem.Professional = "";
                        tem.GraduationDate = null;
                        tem.IsTopEducation = false;
                        for (ushort ii = 1; ii <= sheet1.Rows[i].CellCount; ii++)
                        {
                            int column = sheet1.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.EducationName = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.EducationType = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.EducationaSystem = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    if (sheet1.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet1.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet1.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.GraduationDate = Convert.ToDateTime(sheet1.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 7:
                                    tem.School = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    tem.Professional = sheet1.Rows[i].GetCell(ii).Value == null ? null : sheet1.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 9:
                                    if (sheet1.Rows[i].GetCell(ii).Value != null)
                                        tem.IsTopEducation = sheet1.Rows[i].GetCell(ii).Value.ToString() == "最高学历" ? true : false;
                                    break;

                            }
                        }
                        InEmpEducation.Add(tem);
                    }
                    #endregion

                    #region 学位信息
                    Worksheet sheet2 = doc.Workbook.Worksheets[2];
                    for (ushort i = 2; i <= sheet2.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_DegreeModel tem = new EmpbasicService.Emp_DegreeModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.DegreeName =
                            tem.LearningType = tem.EducationalSystem = tem.School = tem.Professional = "";
                        tem.EducationDate = null;
                        for (ushort ii = 1; ii <= sheet2.Rows[i].CellCount; ii++)
                        {
                            int column = sheet2.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.DegreeName = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.LearningType = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.EducationalSystem = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    if (sheet2.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet2.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet2.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.EducationDate = Convert.ToDateTime(sheet2.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 7:
                                    tem.School = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    tem.Professional = sheet2.Rows[i].GetCell(ii).Value == null ? null : sheet2.Rows[i].GetCell(ii).Value.ToString();
                                    break;

                            }
                        }
                        InEmpDegree.Add(tem);
                    }
                    #endregion

                    #region 简历信息
                    Worksheet sheet3 = doc.Workbook.Worksheets[3];
                    for (ushort i = 2; i <= sheet3.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_ResumeModel tem = new EmpbasicService.Emp_ResumeModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.Unit =
                            tem.Duty = tem.Witness = "";
                        tem.BeginDate = tem.EndDate = null;
                        tem.IsPeriod = false;
                        for (ushort ii = 1; ii <= sheet3.Rows[i].CellCount; ii++)
                        {
                            int column = sheet3.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet3.Rows[i].GetCell(ii).Value == null ? null : sheet3.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet3.Rows[i].GetCell(ii).Value == null ? null : sheet3.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    if (sheet3.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet3.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet3.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.BeginDate = Convert.ToDateTime(sheet3.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 4:
                                    if (sheet3.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet3.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet3.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.EndDate = Convert.ToDateTime(sheet3.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 5:
                                    tem.Unit = sheet3.Rows[i].GetCell(ii).Value == null ? null : sheet3.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    tem.Duty = sheet3.Rows[i].GetCell(ii).Value == null ? null : sheet3.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    tem.Witness = sheet3.Rows[i].GetCell(ii).Value == null ? null : sheet3.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    if (sheet3.Rows[i].GetCell(ii).Value != null)
                                        tem.IsPeriod = sheet3.Rows[i].GetCell(ii).Value.ToString() == "是" ? true : false;
                                    break;

                            }
                        }
                        InEmpResume.Add(tem);
                    }
                    #endregion

                    #region 职务信息
                    Worksheet sheet4 = doc.Workbook.Worksheets[4];
                    for (ushort i = 2; i <= sheet4.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_Duty tem = new EmpbasicService.Emp_Duty();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.DutyNo =
                            tem.DutyName = tem.DutyLevel = tem.DutyAttribute = tem.OrganizationName = tem.Sec = tem.WorkCharge
                            = tem.ServiceMode = tem.JobStatus = tem.IsExceptionalPromotion = "";
                        tem.OKDate = tem.JobDate = null;
                        for (ushort ii = 1; ii <= sheet4.Rows[i].CellCount; ii++)
                        {
                            int column = sheet4.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.DutyNo = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.DutyName = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.DutyLevel = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    tem.DutyAttribute = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    if (sheet4.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet4.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet4.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.OKDate = Convert.ToDateTime(sheet4.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 8:
                                    tem.OrganizationName = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 9:
                                    tem.Sec = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 10:
                                    tem.WorkCharge = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 11:
                                    tem.ServiceMode = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 12:
                                    tem.IsExceptionalPromotion = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 13:
                                    tem.JobStatus = sheet4.Rows[i].GetCell(ii).Value == null ? null : sheet4.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 14:
                                    if (sheet4.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet4.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet4.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.JobDate = Convert.ToDateTime(sheet4.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;

                            }
                        }
                        InEmpDuty.Add(tem);
                    }
                    #endregion

                    #region 奖励信息
                    Worksheet sheet5 = doc.Workbook.Worksheets[5];
                    for (ushort i = 2; i <= sheet5.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_RewardInfoModel tem = new EmpbasicService.Emp_RewardInfoModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.RewardNo =
                            tem.RewardName = tem.RewardReason = tem.OtherRewardReason = tem.OKUnit = "";
                        tem.OKDate = null;
                        for (ushort ii = 1; ii <= sheet5.Rows[i].CellCount; ii++)
                        {
                            int column = sheet5.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.RewardNo = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.RewardName = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.RewardReason = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    tem.OtherRewardReason = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    if (sheet5.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet5.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet5.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.OKDate = Convert.ToDateTime(sheet5.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;
                                case 8:
                                    tem.OKUnit = sheet5.Rows[i].GetCell(ii).Value == null ? null : sheet5.Rows[i].GetCell(ii).Value.ToString();
                                    break;


                            }
                        }
                        InEmpReward.Add(tem);
                    }
                    #endregion

                    #region 处分信息
                    Worksheet sheet6 = doc.Workbook.Worksheets[6];
                    for (ushort i = 2; i <= sheet6.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_PunishmentModel tem = new EmpbasicService.Emp_PunishmentModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.PunishmentName =
                            tem.PunishmentReason = tem.OkUnit = tem.PunishmentNo = tem.PunishmentTimeLimit = "";
                        tem.OKDate = null;
                        for (ushort ii = 1; ii <= sheet6.Rows[i].CellCount; ii++)
                        {
                            int column = sheet6.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.PunishmentNo = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.PunishmentName = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.PunishmentReason = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    tem.OkUnit = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    tem.PunishmentTimeLimit = sheet6.Rows[i].GetCell(ii).Value == null ? null : sheet6.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    if (sheet6.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet6.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet6.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.OKDate = Convert.ToDateTime(sheet6.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;


                            }
                        }
                        InEmpPunish.Add(tem);
                    }
                    #endregion

                    #region 考核信息
                    Worksheet sheet7 = doc.Workbook.Worksheets[7];
                    for (ushort i = 2; i <= sheet7.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_AssessmentModel tem = new EmpbasicService.Emp_AssessmentModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.AssessmentType =
                            tem.AssessmentResult = "";
                        tem.AssessmentDate = null;
                        for (ushort ii = 1; ii <= sheet7.Rows[i].CellCount; ii++)
                        {
                            int column = sheet7.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet7.Rows[i].GetCell(ii).Value == null ? null : sheet7.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet7.Rows[i].GetCell(ii).Value == null ? null : sheet7.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.AssessmentType = sheet7.Rows[i].GetCell(ii).Value == null ? null : sheet7.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.AssessmentResult = sheet7.Rows[i].GetCell(ii).Value == null ? null : sheet7.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    if (sheet7.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet7.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet7.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.AssessmentDate = Convert.ToDateTime(sheet7.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;


                            }
                        }
                        InEmpAssenssment.Add(tem);
                    }
                    #endregion

                    #region 家庭信息
                    Worksheet sheet8 = doc.Workbook.Worksheets[8];
                    for (ushort i = 2; i <= sheet8.Rows.Count - 1; i++)
                    {
                        EmpbasicService.Emp_FamilyRelationModel tem = new EmpbasicService.Emp_FamilyRelationModel();
                        tem.EmpName =
                            tem.EmpNo =
                            tem.Name =
                            tem.Appellation = "";
                        tem.Birthday = null;
                        for (ushort ii = 1; ii <= sheet8.Rows[i].CellCount; ii++)
                        {
                            int column = sheet8.Rows[i].GetCell(ii).Column;
                            switch (column)
                            {
                                case 1:
                                    tem.EmpName = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 2:
                                    tem.EmpNo = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 3:
                                    tem.Name = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 4:
                                    tem.Appellation = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 5:
                                    tem.Unit = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 6:
                                    tem.Duty = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 7:
                                    tem.Political = sheet8.Rows[i].GetCell(ii).Value == null ? null : sheet8.Rows[i].GetCell(ii).Value.ToString();
                                    break;
                                case 8:
                                    if (sheet8.Rows[i].GetCell(ii).Value != null && !string.IsNullOrEmpty(sheet8.Rows[i].GetCell(ii).Value.ToString()))
                                    {
                                        if (IsDateTime(sheet8.Rows[i].GetCell(ii).Value.ToString()))
                                            tem.Birthday = Convert.ToDateTime(sheet8.Rows[i].GetCell(ii).Value.ToString());
                                    }
                                    break;


                            }
                        }
                        InEmpFamily.Add(tem);
                    }
                    #endregion

                    
                    Client.CanDaoRuAllAsync(InEmpBasicModels);
                }
            }
            catch (IOException ex)
            {
                //SilverlightMessageBoxLibrary.Message.ErrorMessage(ex.Message);
                SilverlightMessageBoxLibrary.Message.ErrorMessage("文件正在使用，请关闭文件再次尝试！");
            }
        }
        /// <summary>
        /// 没有重复的姓名+身份证的人员，可以导入数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Client_CanDaoRuAllCompleted(object sender, EmpbasicService.CanDaoRuAllCompletedEventArgs e)
        {
            if (e.Result == true)
            {
                Client.DaoRuAllAsync(InEmpBasicModels, InEmpEducation, InEmpDegree, InEmpResume, InEmpDuty, InEmpReward,
                                     InEmpPunish, InEmpAssenssment, InEmpFamily);
            }
            else
            {
                if(MessageBox.Show("已存在部分导入的人员信息，继续导入将删除重复数据，确定继续吗？","提示",MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    Client.ShanChuDaoRuAllAsync(InEmpBasicModels);
                }
            }
        }

        void Client_ShanChuDaoRuAllCompleted(object sender, ShanChuDaoRuAllCompletedEventArgs e)
        {
            if (e.Result == true)
            {
                
                Client.DaoRuAllAsync(InEmpBasicModels, InEmpEducation, InEmpDegree, InEmpResume, InEmpDuty, InEmpReward,
                                     InEmpPunish, InEmpAssenssment, InEmpFamily);
            }
        }

        void Client_DaoRuAllCompleted(object sender, EmpbasicService.DaoRuAllCompletedEventArgs e)
        {
            SilverlightMessageBoxLibrary.Message.InfoMessage("导入成功！");
            LoadData("0");
        }
        //public static bool IsDateTime(string StrSource)
        //{
        //    return Regex.IsMatch(StrSource, @"^((\d{2}(([02468][048])|([13579][26]))[\-\/\s\.]?((((0?[13578])|(1[02]))[\-\/\s\.]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s\.]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s\.]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s\.]?((((0?[13578])|(1[02]))[\-\/\s\.]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s\.]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s\.]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$");

        //}
        #endregion





    }

}
